:root {
  --bg: #0b0e11;
  --panel: #181a20;
  --panel-2: #1e2329;
  --panel-3: #2b3139;
  --text: #eaecef;
  --muted: #848e9c;
  --line: #2b3139;
  --yellow: #fcd535;
  --yellow-2: #f0b90b;
  --blue: #2b7de9;
  --ok: #0ecb81;
  --bad: #f6465d;
  --warn: #f0b90b;
}
* { box-sizing: border-box; font-family: 'IBM Plex Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--yellow); }
.wrap { min-height: 100vh; background: radial-gradient(circle at top right, rgba(252,213,53,.08), transparent 34%), var(--bg); }
.sidebar { background: #0f1318; color: var(--text); padding: 28px 20px; border-right: 1px solid var(--line); }
.sidebar h3 { margin: 0 0 30px; font-size: 22px; letter-spacing: -.02em; color: var(--yellow); }
.sidebar a { display: flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; padding: 0 14px; border-radius: 12px; font-weight: 700; margin-bottom: 6px; }
.sidebar a:hover { color: var(--text); background: var(--panel-2); }
.main { padding: 34px 38px 118px; overflow: auto; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 8px; font-size: 42px; line-height: 1.05; letter-spacing: -.04em; }
.small { font-size: 14px; color: var(--muted); }
.card { background: linear-gradient(180deg, rgba(30,35,41,.98), rgba(24,26,32,.98)); border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin-bottom: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.card h2, .card h3, .card h4 { margin-top: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.metric-grid-admin { display: grid; grid-template-columns: repeat(6, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; background: linear-gradient(145deg, #1e2329, #181a20); border: 1px solid var(--line); border-radius: 18px; padding: 18px; min-height: 132px; box-shadow: 0 16px 42px rgba(0,0,0,.22); }
.metric-card::after { content: ''; position: absolute; right: -36px; top: -36px; width: 110px; height: 110px; border-radius: 999px; background: rgba(252,213,53,.09); }
.metric-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; font-weight: 700; }
.metric-card strong { display: block; color: var(--text); font-size: 28px; line-height: 1.08; letter-spacing: -.03em; white-space: nowrap; }
.metric-card small { display: block; margin-top: 10px; color: var(--muted); line-height: 1.35; }
.metric-card.compact { min-width: 220px; min-height: auto; }
.metric-card.is-good strong, .status-ok { color: var(--ok); }
.metric-card.is-bad strong, .status-bad { color: var(--bad); }
.metric-card.is-warn strong, .status-zero { color: var(--warn); }
.kpi-revenue strong { color: var(--yellow); }
.kpi-expense strong { color: var(--warn); }
.kpi-deals strong { color: var(--blue); }
.dashboard-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card h3 { margin-bottom: 18px; }
.margin-bars { display: grid; gap: 16px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 76px; gap: 14px; align-items: center; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; color: var(--text); font-weight: 700; }
.bar-label span { color: var(--muted); font-weight: 600; }
.bar-track { height: 16px; border-radius: 999px; background: #0f1318; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 999px; transition: width .25s ease; }
.bar-ok { background: linear-gradient(90deg, #0ecb81, #32d993); }
.bar-bad { background: linear-gradient(90deg, #f6465d, #ff7585); }
.bar-zero { background: linear-gradient(90deg, #f0b90b, #fcd535); }
.bar-percent { color: var(--muted); text-align: right; font-size: 13px; }
.insight-list { display: grid; gap: 12px; }
.insight-list div { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #0f1318; }
.insight-list strong { display: block; color: var(--yellow); font-size: 26px; margin-bottom: 4px; letter-spacing: -.03em; }
.insight-list span { color: var(--muted); }
.button-link, button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px; border-radius: 10px; background: var(--yellow); color: #181a20; border: 0; text-decoration: none; font-weight: 800; cursor: pointer; }
button:hover, .button-link:hover { background: var(--yellow-2); color: #181a20; }
button.danger { background: var(--bad); color: #fff; }
input, select, textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f1318; color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; font-size: 14px; }
th { color: var(--muted); font-weight: 700; }
tr:hover td { background: rgba(255,255,255,.015); }
.notice { background: rgba(14,203,129,.12); border: 1px solid rgba(14,203,129,.35); color: #8ff0c0; border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; font-weight: 800; }
.inline-edit { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
summary { cursor: pointer; color: var(--yellow); font-weight: 700; }
@media (max-width: 1280px) { .metric-grid-admin { grid-template-columns: repeat(3, minmax(190px, 1fr)); } }
@media (max-width: 900px) { .dashboard-columns { grid-template-columns: 1fr; } .page-head { display: block; } .main { padding: 22px 18px 118px; } }
@media (max-width: 760px) { .metric-grid-admin { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 1fr; } .bar-percent { text-align: left; } .page-head h1 { font-size: 32px; } }

/* Admin UI refinements */
.dashboard-analytics { grid-template-columns: 1.1fr .9fr; }
.margin-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.margin-summary div { background: #0f1318; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.margin-summary span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.margin-summary strong { color: var(--yellow); font-size: 22px; white-space: nowrap; }
.finance-table .num, .money-col, .date-col { white-space: nowrap; }
.finance-table .deal-link { color: var(--text); text-decoration: none; font-weight: 800; }
.finance-table .deal-link:hover { color: var(--yellow); }
.deals-head form { margin-left: auto; }
.filter-card .row { align-items: center; }
.button-outline, .ghost-button { background: transparent; color: var(--yellow); border: 1px solid rgba(252,213,53,.55); }
.button-outline:hover, .ghost-button:hover { background: rgba(252,213,53,.12); color: var(--yellow); }
.deals-table { table-layout: fixed; }
.deals-table .deal-col { width: 25%; }
.deals-table .money-col { width: 13.5%; }
.deals-table .percent-col { width: 7%; text-align: right; }
.deals-table .status-col { width: 7%; text-align: center; }
.status-icon { font-size: 18px; font-weight: 900; }
.deal-actions-row td { background: rgba(255,255,255,.015); }
.deal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.quick-form { display: grid; grid-template-columns: 120px 150px minmax(140px, 1fr) auto; gap: 8px; align-items: center; }
.records-block { position: relative; margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #0f1318; }
.records-block > strong { display: block; margin-bottom: 10px; color: var(--yellow); }
.record-line { display: grid; grid-template-columns: 170px 140px minmax(160px, 1fr) 42px; gap: 8px; align-items: center; margin: 8px 50px 8px 0; }
.records-block .record-line select { min-width: 150px; }
.record-delete { display: flex; justify-content: flex-end; margin-top: -48px; margin-bottom: 12px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; border-radius: 10px; background: transparent; border: 1px solid var(--line); color: var(--text); font-size: 18px; line-height: 1; }
.icon-button:hover, .icon-button.save:hover { border-color: var(--yellow); color: var(--yellow); background: rgba(252,213,53,.1); }
.icon-button.delete { font-size: 24px; }
.icon-button.delete:hover { border-color: var(--bad); color: var(--bad); background: rgba(246,70,93,.1); }
.icon-button.edit { display: inline-flex; color: var(--text); list-style: none; }
.icon-button.edit::-webkit-details-marker { display: none; }
.actions-col { width: 92px; white-space: nowrap; }
.expenses-table .money-col { width: 150px; }
.expenses-table .date-col { width: 130px; }
.action-delete-form { display: inline-flex; margin-left: 6px; }
.row-actions-details { display: inline-block; position: relative; }
.row-actions-details[open] { display: block; }
.row-actions-details[open] .inline-edit { position: absolute; right: 0; top: 42px; z-index: 5; width: min(760px, 80vw); padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #0f1318; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.expense-chart-grid { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: center; }
.donut-wrap { display: flex; justify-content: center; align-items: center; }
.donut-chart { width: 240px; height: 240px; transform: rotate(-90deg); }
.donut-hole { fill: transparent; stroke: #0f1318; stroke-width: 8; }
.donut-segment { fill: transparent; stroke-width: 8; transition: stroke-width .2s ease, opacity .2s ease; cursor: pointer; }
.donut-segment:hover { stroke-width: 9.5; opacity: .85; }
.category-legend { display: grid; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 14px minmax(140px, 1fr) 150px 70px; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #0f1318; }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; }
.legend-row span, .legend-row em { color: var(--muted); font-style: normal; text-align: right; }
.legend-row strong { color: var(--text); }
@media (max-width: 1200px) { .deal-actions { grid-template-columns: 1fr; } .quick-form { grid-template-columns: 1fr; } .record-line { grid-template-columns: 1fr; margin-right: 0; } .record-delete { margin-top: 0; } }
@media (max-width: 900px) { .dashboard-analytics, .expense-chart-grid { grid-template-columns: 1fr; } .deals-table { table-layout: auto; } .legend-row { grid-template-columns: 14px 1fr; } .legend-row span, .legend-row em { text-align: left; } }

/* Dashboard period and timeline */
.dashboard-head strong { color: var(--yellow); }
.period-card { padding: 14px; }
.period-form { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.period-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.period-tab { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #0f1318; cursor: pointer; font-weight: 800; }
.period-tab input { display: none; }
.period-tab.active { color: #181a20; background: var(--yellow); border-color: var(--yellow); }
.custom-period { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline-card { padding-bottom: 16px; }
.timeline-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 14px; }
.timeline-head h3 { margin-bottom: 6px; }
.timeline-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; font-weight: 800; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.dot.income { background: var(--yellow); }
.dot.expense { background: var(--bad); }
.dot.margin { background: var(--ok); }
.timeline-svg { width: 100%; height: 290px; display: block; background: linear-gradient(180deg, rgba(15,19,24,.85), rgba(15,19,24,.35)); border: 1px solid var(--line); border-radius: 16px; padding: 4px; }
.axis { stroke: #2b3139; stroke-width: 1; vector-effect: non-scaling-stroke; }
.timeline-line { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; opacity: .95; }
.timeline-line.income { stroke: var(--yellow); }
.timeline-line.expense { stroke: var(--bad); }
.timeline-line.margin { stroke: var(--ok); }
.timeline-point { fill: var(--yellow); stroke: #0b0e11; stroke-width: 2; vector-effect: non-scaling-stroke; }
.timeline-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.timeline-footer strong { color: var(--text); }
@media (max-width: 760px) { .timeline-head { display: block; } .period-form { display: block; } .custom-period { margin-top: 10px; } .timeline-svg { height: 220px; } }

/* Deal ledger layout fix */
.deal-ledger { display: grid; gap: 18px; padding: 12px 4px; }
.ledger-section { border: 1px solid var(--line); border-radius: 16px; background: #0f1318; padding: 16px; }
.ledger-title { color: var(--yellow); font-weight: 900; font-size: 18px; margin-bottom: 12px; }
.ledger-table { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 8px 10px; align-items: center; }
.ledger-row { display: grid; grid-template-columns: 180px 160px minmax(160px, 1fr) 42px; gap: 10px; align-items: center; min-width: 0; }
.ledger-row-expense { grid-template-columns: 170px 145px 155px minmax(150px, 1fr) 42px; }
.ledger-delete { display: flex; justify-content: center; align-items: center; margin: 0; }
.ledger-empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.ledger-add { display: grid; gap: 10px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ledger-add-income { grid-template-columns: 180px 160px minmax(220px, 1fr) auto; }
.ledger-add-expense { grid-template-columns: 180px 150px 160px minmax(220px, 1fr) auto; }
.ledger-divider { height: 2px; border-radius: 999px; background: linear-gradient(90deg, transparent, rgba(234,236,239,.75), transparent); }
.ledger-section input, .ledger-section select { min-width: 0; width: 100%; }
.ledger-section .ghost-button { white-space: nowrap; }
@media (max-width: 1300px) { .ledger-table { grid-template-columns: 1fr 42px; } .ledger-row, .ledger-row-expense, .ledger-add-income, .ledger-add-expense { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .ledger-table { grid-template-columns: 1fr; } .ledger-row, .ledger-row-expense, .ledger-add-income, .ledger-add-expense { grid-template-columns: 1fr; } .ledger-delete { justify-content: flex-start; } }

/* Active sidebar state */
.sidebar a.active { position: relative; color: var(--text); background: linear-gradient(90deg, rgba(252,213,53,.18), rgba(252,213,53,.04)); border: 1px solid rgba(252,213,53,.22); }
.sidebar a.active::before { content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 4px; border-radius: 999px; background: var(--yellow); box-shadow: 0 0 18px rgba(252,213,53,.55); }

/* Bottom app navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 8px;
  width: min(760px, calc(100vw - 36px));
  padding: 10px;
  transform: translateX(-50%);
  border: 1px solid rgba(252,213,53,.18);
  border-radius: 22px;
  background: rgba(15,19,24,.88);
  box-shadow: 0 20px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(18px);
}
.bottom-nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 16px;
  font-weight: 900;
}
.bottom-nav a span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 9px;
  background: rgba(255,255,255,.05);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}
.bottom-nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.bottom-nav a.active {
  color: var(--yellow);
  border-color: rgba(252,213,53,.6);
  background: linear-gradient(135deg, rgba(252,213,53,.18), rgba(252,213,53,.035));
  box-shadow: inset 0 0 0 1px rgba(252,213,53,.12), 0 0 28px rgba(252,213,53,.08);
}
.bottom-nav a.active span {
  color: #181a20;
  background: var(--yellow);
}
.settings-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0f1318;
}
.settings-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 900;
}
.settings-tabs a:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.settings-tabs a.active {
  color: #181a20;
  background: var(--yellow);
}
@media (max-width: 760px) {
  .bottom-nav {
    grid-template-columns: repeat(4, 1fr);
    width: calc(100vw - 20px);
    bottom: 10px;
    padding: 7px;
    border-radius: 18px;
  }
  .bottom-nav a {
    min-height: 48px;
    padding: 0 6px;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
  }
}
