:root {
  --ink: #0b1f33;
  --muted: #64748b;
  --panel: #ffffff;
  --canvas: #f4f7fb;
  --line: #d8e0ea;
  --blue: #1f6fc7;
  --teal: #0f766e;
  --green: #13804e;
  --gold: #d6b94d;
  --orange: #f28c28;
  --red: #dc2626;
  --dark: #081927;
  --slate: #4b5160;
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button, input, select, textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--dark);
  color: white;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(135deg, #0f766e, #f59e0b);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: .2px;
}

.brand p {
  margin: 2px 0 0;
  color: #cbd5e1;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  padding-top: 16px;
}

.nav button {
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: white;
  padding: 10px 12px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.nav button.active {
  background: var(--blue);
  border-color: #8cc0ff;
}

.workspace {
  min-width: 0;
  padding: 18px 22px 34px;
}

.topbar {
  min-height: 76px;
  background: var(--dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: 8px 8px 0 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: #f8d66d;
  font-size: 12px;
  font-style: italic;
}

.topbar h2 {
  margin: 0;
  font-size: 25px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button, .file-button {
  border: none;
  background: var(--blue);
  color: white;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.ghost {
  background: #eaf2ff;
  color: #134c8e;
}

.danger {
  background: #fee2e2;
  color: #991b1b;
}

.file-button input {
  display: none;
}

.hidden {
  display: none !important;
}

.cloud-status {
  color: #dbeafe;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.quick-links {
  display: none;
}

.quick-heading {
  background: var(--slate);
  color: white;
  font-weight: 800;
  padding: 8px 14px;
  text-transform: uppercase;
  font-size: 13px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 0 0 10px;
}

.quick-grid button {
  background: var(--blue);
  border-radius: 0;
  min-height: 32px;
}

.view {
  display: grid;
  gap: 18px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}

.card {
  padding: 14px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.card .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 900;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--dark);
  color: white;
  padding: 10px 14px;
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  border: 1px solid var(--line);
  padding: 8px 9px;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: #0f7890;
  color: white;
  text-align: center;
  font-weight: 900;
}

td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.month-cell {
  background: var(--dark);
  color: white;
  font-weight: 900;
  text-align: center;
}

.target { background: #d6b94d; font-weight: 800; }
.actual { background: #eef2f7; }
.good { color: var(--green); font-weight: 900; }
.bad { color: var(--red); font-weight: 900; }
.carry { color: var(--orange); font-weight: 900; }

.entry-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 800;
}

.login-panel {
  max-width: 520px;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.login-message {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.auth-locked .sidebar {
  display: none;
}

.auth-locked .app-shell {
  grid-template-columns: 1fr;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: white;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar input, .toolbar select {
  max-width: 220px;
}

.empty {
  color: var(--muted);
  padding: 22px;
}

.split {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.5fr);
  gap: 18px;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.pill {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 8px 11px;
  font-weight: 800;
  color: var(--ink);
}

.receipt-current {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.receipt-link {
  font-weight: 900;
  color: var(--blue);
}

.report-controls {
  overflow: visible;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.report-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.report-period {
  color: #dbeafe;
  font-size: 12px;
  font-weight: 800;
}

.analytics-cards {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.analytics-table td:last-child {
  min-width: 180px;
}

.bar-track {
  height: 12px;
  background: #e5edf7;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #cad7e7;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .split { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .report-actions { justify-content: flex-start; }
  .analytics-cards { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .sidebar,
  .top-actions,
  .quick-links,
  .report-controls,
  .toolbar button {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .topbar,
  .panel-header {
    border-radius: 0;
  }

  .panel,
  .card {
    box-shadow: none;
    break-inside: avoid;
  }
}
