:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #dbe5ef;
  --panel: #ffffff;
  --bg: #eef6fc;
  --blue: #1766a8;
  --blue-dark: #0b365f;
  --blue-soft: #d9efff;
  --gold: #f3b61f;
  --danger: #b91c1c;
  --success: #047857;
  --shadow: 0 18px 48px rgba(11, 54, 95, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--blue); text-decoration: none; }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
label { display: grid; gap: 7px; color: #334155; font-weight: 700; font-size: 13px; }
small, .muted { color: var(--muted); display: block; font-weight: 500; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 264px;
  background: #07111d;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 900;
}
.brand img { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; background: #0f2438; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a {
  color: #c8d7e8;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 700;
}
.sidebar nav a.active, .sidebar nav a:hover {
  color: #fff;
  background: linear-gradient(90deg, var(--blue), #1d9fe4);
}
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 14px;
  display: grid;
  gap: 4px;
}
.sidebar-footer a { color: var(--gold); }
.mobile-menu {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  width: 58px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
}

.main {
  margin-left: 264px;
  min-height: 100vh;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 20px;
}
.topbar p {
  color: var(--blue);
  font-weight: 900;
  margin: 0 0 3px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(26px, 4vw, 38px); color: var(--blue-dark); }
h2 { font-size: 19px; }
.panel, .metric {
  background: var(--panel);
  border: 1px solid rgba(23, 102, 168, .12);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; margin-bottom: 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  padding: 18px;
  min-height: 112px;
  display: grid;
  align-content: space-between;
}
.metric span { color: var(--muted); font-weight: 800; }
.metric strong { color: var(--blue-dark); font-size: 24px; }
.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}
.wide { grid-column: 1 / -1; }
.stack { display: grid; gap: 15px; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue-dark);
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 10px;
  font-weight: 900;
  cursor: pointer;
}
.btn.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: #fee2e2;
  color: var(--danger);
  font-size: 20px;
  cursor: pointer;
}
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 15px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 800;
}
.alert.success { background: #dcfce7; color: var(--success); }
.alert.danger { background: #fee2e2; color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--blue-dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}
.empty { text-align: center; color: var(--muted); padding: 28px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 900;
  font-size: 12px;
}
.row-actions { white-space: nowrap; }
.row-actions .btn { margin: 2px; }
.gst-box {
  border: 1px solid var(--line);
  background: #f8fbff;
  border-radius: 14px;
  padding: 14px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.switch-row select { max-width: 120px; }
.gst-fields { margin-top: 14px; }
.line-items {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.line-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--blue-soft);
}
.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 140px 42px;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 18px;
}
.summary-grid span {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}
.summary-grid strong { display: block; color: var(--blue-dark); margin-top: 4px; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.check input { width: auto; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(23,102,168,.12), rgba(243,182,31,.10)),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  background: #07111d;
  border-radius: 14px;
  margin-bottom: 14px;
}

.print-body {
  background: #dbe5ef;
  color: #111;
  padding: 24px;
}
.print-actions {
  width: 210mm;
  max-width: 100%;
  margin: 0 auto 12px;
  text-align: right;
}
.doc-sheet {
  width: 210mm;
  min-height: 297mm;
  max-width: 100%;
  margin: 0 auto;
  background: #030303;
  color: #d1d5db;
  padding: 10mm 8mm 0;
  position: relative;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.doc-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #0e8eda;
  padding-bottom: 8px;
}
.doc-brand {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.doc-brand img {
  width: 25mm;
  height: 25mm;
  object-fit: contain;
  background: #08284b;
}
.doc-brand h1 {
  color: #777;
  font-size: 21px;
  line-height: 1.1;
  margin: 0 0 4px;
}
.doc-brand p, .doc-client p, .bank p {
  margin: 1px 0;
  font-size: 10px;
}
.doc-meta {
  min-width: 30mm;
  text-align: right;
  display: grid;
  gap: 2px;
  color: #858585;
  font-size: 10px;
}
.doc-meta strong { color: #7d7d7d; }
.doc-client {
  padding: 8px 0 12px;
  color: #c7c7c7;
}
.doc-client strong { color: #7d7d7d; font-size: 10px; }
.doc-client h2 { font-size: 14px; color: #bcbcbc; margin: 4px 0 2px; }
.doc-table {
  border-collapse: collapse;
  width: 100%;
  color: #111;
  font-size: 12px;
}
.doc-table th {
  background: #1766a8;
  color: #fff;
  border: 2px solid #e5eef7;
  font-size: 13px;
  text-transform: none;
  text-align: center;
  padding: 5px;
}
.doc-table td {
  border-left: 2px solid #e5eef7;
  border-right: 2px solid #e5eef7;
  border-bottom: 0;
  padding: 6px;
  height: 26px;
  background: #fff;
}
.doc-table tbody tr:nth-child(even) td {
  background: #1766a8;
  color: #111;
}
.doc-table td:first-child,
.doc-table td:nth-child(3),
.doc-table td:nth-child(4),
.doc-table td:nth-child(5) {
  text-align: center;
}
.doc-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68mm;
  gap: 16px;
  margin-top: 10mm;
  align-items: start;
}
.bank {
  color: #777;
  font-size: 10px;
}
.bank .note {
  color: #777;
  margin-top: 14px;
}
.doc-totals {
  color: #fff;
  font-weight: 900;
}
.doc-totals th, .doc-totals td {
  border: 2px solid #e5eef7;
  background: #1766a8;
  color: #fff;
  padding: 6px;
}
.doc-totals td { text-align: right; font-size: 14px; }
.doc-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 17px;
  background: #1766a8;
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .summary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .mobile-menu { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    margin-left: 0;
    padding: 68px 14px 22px;
  }
  .topbar { align-items: flex-start; }
  .cards, .form-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row input:first-child { grid-column: 1 / -1; }
  .doc-sheet { width: 100%; min-height: auto; padding: 16px 12px 26px; }
  .doc-header, .doc-bottom { grid-template-columns: 1fr; display: grid; }
  .doc-meta { text-align: left; }
  .doc-table { font-size: 10px; }
}

@media print {
  @page { size: A4; margin: 0; }
  body.print-body { background: #fff; padding: 0; }
  .print-actions { display: none; }
  .doc-sheet {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    margin: 0;
  }
}
