:root {
  --bg: #07090c;
  --surface: #101419;
  --surface-2: #151a20;
  --surface-3: #1b222a;
  --line: #29323c;
  --line-strong: #3b4652;
  --text: #f5f7fa;
  --muted: #9aa5b1;
  --muted-2: #66717d;
  --lime: #a8f43d;
  --lime-2: #7fd122;
  --orange: #ffad45;
  --red: #ff6670;
  --blue: #63bfff;
  --violet: #b88aff;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
  --radius: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.ambient { display: none; }

.app-shell { min-height: 100vh; }
.boot-screen, .blocked-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
  padding: 36px;
}
.brand-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 28px;
  color: #071006;
  font-weight: 950;
  letter-spacing: -2px;
  background: var(--lime);
  border: 1px solid #c8ff7f;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .34);
}
.loader {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--lime);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.layout { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: calc(22px + var(--safe-top)) 16px 24px;
  border-right: 1px solid var(--line);
  background: #0b0f13;
  z-index: 30;
}
.logo-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.logo-mini {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--lime); color: #071006; font-weight: 950;
  border: 1px solid #c8ff7f;
  box-shadow: none;
}
.logo-copy strong { display: block; font-size: 16px; }
.logo-copy span { color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav-btn {
  width: 100%; border: 0; padding: 12px 13px; border-radius: 15px;
  display: flex; align-items: center; gap: 12px; color: var(--muted);
  background: transparent; text-align: left; transition: .2s ease;
}
.nav-btn:hover { background: #151a20; color: var(--text); }
.nav-btn.active { color: #071006; background: var(--lime); font-weight: 800; box-shadow: none; }
.nav-icon { width: 24px; text-align: center; font-size: 18px; }
.sidebar-user {
  position: absolute; bottom: 20px; left: 16px; right: 16px; padding: 13px;
  border: 1px solid var(--line); border-radius: 16px; background: #13181e;
}
.sidebar-user strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { color: var(--muted); font-size: 12px; }

.main { grid-column: 2; width: 100%; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(16px + var(--safe-top)) clamp(18px, 4vw, 46px) 14px;
  background: #090c10;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: clamp(21px, 3vw, 30px); letter-spacing: -.7px; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 9px; }
.icon-btn, .ghost-btn, .primary-btn, .danger-btn {
  border: 1px solid var(--line); border-radius: 14px; min-height: 42px; padding: 0 15px;
  color: var(--text); background: #151a20; transition: .18s ease;
}
.icon-btn { width: 42px; padding: 0; }
.icon-btn:hover, .ghost-btn:hover { background: #202730; transform: translateY(-1px); }
.primary-btn {
  color: #12170c; border: 0; font-weight: 850;
  background: var(--lime);
  box-shadow: none;
}
.primary-btn:hover { transform: translateY(-1px); background: #baff58; box-shadow: none; }
.danger-btn { color: #ffd7da; border-color: rgba(255,98,107,.25); background: rgba(255,98,107,.1); }
.small-btn { min-height: 34px; padding: 0 11px; border-radius: 11px; font-size: 13px; }

.content { padding: 10px clamp(18px, 4vw, 46px) calc(100px + var(--safe-bottom)); max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 6px 0 18px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head p { color: var(--muted); margin: 5px 0 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 9px; }

.alert-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 18px; border: 1px solid rgba(255,173,61,.42); border-radius: 18px;
  background: #1a1711;
  box-shadow: none; margin-bottom: 16px;
}
.alert-banner strong { color: #ffd090; }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 16px var(--orange); flex: 0 0 auto; }
.alert-copy { display: flex; gap: 11px; align-items: center; }

.grid { display: grid; gap: 15px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow); overflow: hidden;
}
.card::before {
  content: none;
}
.card-pad { padding: 20px; }
.metric-label { color: var(--muted); font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; }
.metric-value { font-size: clamp(27px, 4vw, 42px); font-weight: 900; letter-spacing: -1.8px; margin-top: 10px; }
.metric-sub { margin-top: 6px; color: var(--muted); font-size: 13px; }
.metric-value.lime { color: var(--lime); text-shadow: none; }
.metric-value.orange { color: var(--orange); }
.metric-value.red { color: var(--red); }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px; }
.section-title h3 { margin: 0; font-size: 13px; letter-spacing: 1.8px; color: #c7cbbf; text-transform: uppercase; }
.section-title span { color: var(--muted); font-size: 12px; }

.finance-snapshot { padding: 18px; }
.finance-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 8px 0; color: var(--muted); }
.finance-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.finance-row.total { border-top: 1px dashed var(--line-strong); margin-top: 8px; padding-top: 15px; font-weight: 800; }
.positive { color: var(--lime) !important; }
.negative { color: var(--red) !important; }
.warning { color: var(--orange) !important; }

.forecast-card { padding: 13px 18px; }
.forecast-row { display: grid; grid-template-columns: 78px 1fr 74px; align-items: center; gap: 14px; padding: 11px 8px; border-bottom: 1px solid rgba(255,255,255,.055); border-radius: 12px; }
.forecast-row:last-child { border-bottom: 0; }
.forecast-row.today { background: rgba(183,255,54,.09); }
.forecast-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.forecast-row.today .forecast-date { color: var(--text); font-weight: 800; }
.bar-track { height: 26px; border-radius: 9px; background: #151a20; overflow: hidden; }
.bar-fill { height: 100%; min-width: 3px; border-radius: 9px; background: var(--lime); box-shadow: none; }
.forecast-value { text-align: right; font-weight: 750; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1 1 260px; }
.search-wrap span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; color: var(--text);
  background: #151a20; outline: none; transition: .18s ease;
}
.input, .select { height: 44px; padding: 0 13px; }
.search-wrap .input { padding-left: 40px; }
.textarea { min-height: 92px; resize: vertical; padding: 12px 13px; }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(183,255,54,.55); box-shadow: 0 0 0 3px rgba(183,255,54,.08); }
.select option { color: #111; }

.table-card { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: 13px 16px; color: var(--muted); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; text-align: left; background: #11161b; position: sticky; top: 0; }
.data-table td { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.055); vertical-align: middle; }
.data-table tr:hover td { background: #11161b; }
.primary-cell strong { display: block; }
.primary-cell span { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }

.status { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; background: #181e25; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 10px currentColor; }
.status.active, .status.free, .status.done, .status.paid { color: var(--lime); background: rgba(183,255,54,.08); }
.status.pending, .status.waiting, .status.connecting, .status.new, .status.draft { color: var(--orange); background: rgba(255,173,61,.08); }
.status.expired, .status.overdue, .status.blocked, .status.cancelled { color: var(--red); background: rgba(255,98,107,.09); }
.status.occupied, .status.in_progress { color: var(--blue); background: rgba(107,196,255,.08); }
.status.frozen { color: var(--violet); background: rgba(189,135,255,.09); }

.cards-list { display: grid; gap: 10px; }
.list-item {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(150px, .8fr) minmax(120px, .7fr) auto;
  align-items: center; gap: 14px; padding: 15px 17px; border: 1px solid var(--line);
  border-radius: 18px; background: #13181e; transition: .18s ease;
}
.list-item:hover { transform: translateY(-1px); border-color: var(--line-strong); background: #181e25; }
.list-item .sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.list-actions { display: flex; gap: 7px; justify-content: flex-end; }

.empty { text-align: center; padding: 46px 24px; color: var(--muted); }
.empty .empty-icon { font-size: 34px; margin-bottom: 10px; }

.tabs { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn { border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #13181e; padding: 9px 13px; }
.tab-btn.active { color: #111; background: var(--lime); border-color: transparent; font-weight: 800; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center;
  padding: 18px; background: rgba(0,0,0,.68); backdrop-filter: blur(10px);
  animation: fadeIn .16s ease;
}
.modal {
  width: min(680px, 100%); max-height: min(88vh, 900px); overflow: auto;
  border: 1px solid var(--line-strong); border-radius: 26px;
  background: var(--surface-2); box-shadow: 0 28px 90px rgba(0,0,0,.65);
  animation: modalUp .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalUp { from { transform: translateY(18px); opacity: .4; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #151a20; z-index: 2; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 18px; }

.toast-root { position: fixed; right: 16px; top: calc(16px + var(--safe-top)); z-index: 200; display: grid; gap: 9px; width: min(370px, calc(100vw - 32px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 15px; background: #151a20; box-shadow: var(--shadow); animation: toastIn .2s ease; }
.toast.error { border-color: rgba(255,98,107,.4); }
.toast.success { border-color: rgba(183,255,54,.36); }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

.bottom-nav { display: none; }
.skeleton { height: 110px; border-radius: var(--radius); background: #171d23; animation: skeletonPulse 1.3s ease-in-out infinite; }
@keyframes skeletonPulse { 50% { opacity: .62; } }

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

@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { display: none; }
  .main { width: 100%; }
  .topbar { padding-left: 17px; padding-right: 17px; }
  .content { padding-left: 14px; padding-right: 14px; }
  .grid.stats, .grid.two, .grid.three { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { border-radius: 20px; }
  .card-pad { padding: 16px; }
  .metric-value { font-size: 29px; }
  .list-item { grid-template-columns: 1fr auto; }
  .list-item > :nth-child(2), .list-item > :nth-child(3) { display: none; }
  .bottom-nav {
    display: flex; position: fixed; z-index: 50; left: 9px; right: 9px; bottom: calc(8px + var(--safe-bottom));
    padding: 7px; gap: 3px; overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 20px;
    background: #0f1419; box-shadow: 0 16px 50px rgba(0,0,0,.5);
  }
  .bottom-nav .nav-btn { min-width: 66px; justify-content: center; flex-direction: column; gap: 2px; padding: 7px 8px; font-size: 10px; border-radius: 14px; }
  .bottom-nav .nav-icon { font-size: 18px; }
  .page-head { align-items: flex-start; }
  .page-head .actions-row { justify-content: flex-end; }
  .forecast-row { grid-template-columns: 62px 1fr 58px; gap: 8px; padding-inline: 3px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { border-radius: 26px 26px 0 0; max-height: 92vh; }
}

@media (max-width: 480px) {
  .grid.stats, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .top-actions .ghost-btn { display: none; }
  .alert-banner { align-items: flex-start; }
  .page-head { display: grid; }
  .page-head .actions-row { justify-content: flex-start; }
}

/* v1.1 — согласования компенсаций */
.status.approved { color: var(--lime); background: rgba(183,255,54,.08); }
.status.rejected { color: var(--red); background: rgba(255,98,107,.09); }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.4; }
.input[readonly] { opacity: .78; cursor: not-allowed; background: #11161b; }
.compensation-row { border-left: 2px solid rgba(255,173,61,.35); }
.danger-btn { border-color: rgba(255,98,107,.28) !important; color: var(--red) !important; }
@media (max-width: 760px) {
  .compensation-row .list-actions { flex-wrap: wrap; }
}
