:root {
  --bg: #0b0b0c;
  --panel: #131316;
  --panel-2: #18181c;
  --line: #2a2a31;
  --text: #ece9e4;
  --muted: #9b9790;
  --accent: #e11d25;
  --ok: #2e9e6b;
  --err: #c0392b;
  --warn: #d9a441;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: #ff8d92; text-decoration: none; }
a:hover { text-decoration: underline; }

.top { display: block; padding: 10px 22px 0; background: rgba(11, 11, 12, .97); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.top__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top__brand { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.top__brand span { display: block; font-size: 10px; font-weight: 600; letter-spacing: .16em; color: var(--muted); }
.tabs { margin-top: 10px; padding-bottom: 8px; display: flex; gap: 6px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.tab:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.tab.is-active { background: var(--accent); color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }
h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
h2 { margin: 0 0 14px; font-size: 17px; }
h3 { margin: 22px 0 10px; font-size: 15px; }
.muted { color: var(--muted); font-size: 12.5px; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.stat strong { display: block; font-size: 22px; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.pagehead { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.pagehead .muted { margin: 6px 0 0; }

.card { margin-bottom: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.form { display: grid; gap: 12px; }
.form--compact { padding-top: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select, .search input, .inline input, .inline select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e0e11;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .search input:focus { outline: 2px solid rgba(225, 29, 37, .4); border-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1b1b20;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: #45454f; text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #f02a32; }
.btn--ghost { background: transparent; }
.btn--danger { background: rgba(192, 57, 43, .16); border-color: rgba(192, 57, 43, .5); color: #f0a49c; }
.btn--sm { padding: 7px 11px; font-size: 12.5px; }
.iconbtn { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: #1b1b20; color: var(--muted); cursor: pointer; line-height: 1; }
.iconbtn:hover { color: #ffb3b7; border-color: rgba(225, 29, 37, .5); }

.search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1 1 260px; width: auto; }
.inline { display: flex; align-items: end; gap: 8px; }
.inline input { width: auto; }

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid rgba(42, 42, 49, .7); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.rowlink { cursor: pointer; }
.rowlink:hover td { background: rgba(255, 255, 255, .02); }

.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; }
.status--new { background: rgba(217, 164, 65, .15); color: #e7c47e; }
.status--done { background: rgba(46, 158, 107, .16); color: #9fe3c1; }
.status--cancel { background: rgba(192, 57, 43, .16); color: #f0a49c; }

.carlist { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.carlist li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.carlist .muted { display: block; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pager__item { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 13px; }
.pager__item.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.flash { margin: 0 0 18px; padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.flash--ok { background: rgba(46, 158, 107, .14); border: 1px solid rgba(46, 158, 107, .4); color: #9fe3c1; }
.flash--error { background: rgba(192, 57, 43, .14); border: 1px solid rgba(192, 57, 43, .45); color: #f0a49c; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(360px, calc(100vw - 36px)); padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.login__brand { font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 18px; text-align: center; }
.login__brand span { display: block; margin-top: 4px; font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: #0e0e11; color: var(--text); font: inherit; }
.login .btn { width: 100%; margin-top: 14px; }
.login__hint { margin: 14px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .wrap { padding: 18px 14px 60px; }
  h1 { font-size: 22px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .pagehead { flex-direction: column; }
  .pagehead .btn { width: 100%; }
  .search .btn { flex: 1 1 auto; }
  .inline { width: 100%; }
  .inline input { flex: 1; }
  .table { font-size: 12.5px; }
  .table td, .table th { padding: 8px 6px; }
  .stat strong { font-size: 19px; }
}

.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.attach { margin: 0; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.attach__media { display: block; aspect-ratio: 4 / 3; border-radius: 7px; overflow: hidden; background: #000; }
.attach__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach__doc { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; border-radius: 7px; background: #0e0e11; border: 1px dashed var(--line); color: #ffb3b7; font-weight: 700; letter-spacing: .1em; }
.attach figcaption { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attach__name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach form { position: absolute; top: 6px; right: 6px; }
.attach .iconbtn { background: rgba(10, 10, 11, .8); }
.periodbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.periodtabs { display: flex; gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.ptab { padding: 7px 13px; border-radius: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.ptab:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.ptab.is-active { background: var(--accent); color: #fff; }
.periodnav { display: flex; align-items: center; gap: 8px; }
.daysep td { background: #101013; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; }

@media (max-width: 620px) {
  .periodbar { flex-direction: column; align-items: stretch; }
  .periodnav { justify-content: space-between; }
  .periodnav .inline { flex: 1; }
  .periodnav .inline input { flex: 1; }
}
.periodtabs { align-items: center; }
.periodtabs__label { padding: 0 8px 0 8px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ptab { padding: 8px 14px; font-size: 13.5px; }
.periodform { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.periodform__label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pchoice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}
.pchoice:hover { border-color: #45454f; color: var(--text); }
.pchoice.is-active { border-color: var(--accent); background: rgba(225, 29, 37, .12); color: #fff; }
.pchoice input { position: absolute; opacity: 0; pointer-events: none; }
.pchoice__box {
  width: 18px;
  height: 18px;
  flex: none;
  border: 1.5px solid #4a4a54;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  color: transparent;
}
.pchoice input:checked + .pchoice__box { background: var(--accent); border-color: var(--accent); color: #fff; }
.pchoice input:checked + .pchoice__box::before { content: "✓"; }
.pchoice input:focus-visible + .pchoice__box { outline: 2px solid rgba(225, 29, 37, .5); outline-offset: 2px; }

@media (max-width: 620px) {
  .periodform { gap: 8px; }
  .periodform__label { width: 100%; }
  .pchoice { flex: 1 1 calc(50% - 8px); justify-content: flex-start; }
}
.perioddd { position: relative; }
.periodbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.periodbtn:hover { border-color: #45454f; }
.periodbtn__label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.periodbtn svg { transition: transform .15s; color: var(--muted); }
.perioddd.is-open .periodbtn svg { transform: rotate(180deg); }
.periodmenu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 210px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
.perioddd.is-open .periodmenu { display: block; }
.periodmenu .pchoice { width: 100%; justify-content: flex-start; border: 0; background: transparent; padding: 9px 10px; color: var(--text); }
.periodmenu .pchoice:hover { background: var(--panel-2); }
.periodmenu .pchoice.is-active { background: rgba(225, 29, 37, .12); }

@media (max-width: 620px) {
  .perioddd { width: 100%; }
  .periodbtn { width: 100%; justify-content: space-between; }
  .periodmenu { width: 100%; min-width: 0; }
}
.periodnav { flex-wrap: wrap; }
.periodnav .inline { display: flex; align-items: center; gap: 6px; }
.periodnav .inline input[type=date] { width: auto; padding: 8px 10px; }
.newcar { margin: 2px 0 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
/* --- finance --- */
.stat--in strong { color: #63d69a; }
.stat--out strong { color: #ff9b93; }
.right { text-align: right; }
.money--in { color: #63d69a; font-weight: 600; white-space: nowrap; }
.money--out { color: #ff9b93; font-weight: 600; white-space: nowrap; }
.typebadge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; }
.typebadge--income { background: rgba(46, 158, 107, .16); color: #9fe3c1; }
.typebadge--expense { background: rgba(192, 57, 43, .16); color: #f0a49c; }
.typefilter { display: flex; gap: 4px; margin: 0 0 14px; flex-wrap: wrap; }
.typefilter__item { padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; }
.typefilter__item:hover { border-color: #45454f; color: var(--text); text-decoration: none; }
.typefilter__item.is-active { background: var(--panel); border-color: #45454f; color: var(--text); }
.inline-form { display: inline-block; margin: 0 0 0 4px; vertical-align: middle; }
.table td .iconbtn { display: inline-grid; place-items: center; vertical-align: middle; }