@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --paper: #F6F7F9;
  --paper-raised: #FFFFFF;
  --ink: #1B2430;
  --ink-soft: #57626F;
  --line: #DCE1E6;
  --accent: #0F8A5F;      /* GST collected / positive figures */
  --accent-soft: #E4F3EC;
  --stamp: #B23A2E;       /* cancelled / warnings */
  --stamp-soft: #FBEAE8;
  --gold: #C48A2A;        /* highlight accent, used sparingly */

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0 0 0.4em 0;
  letter-spacing: -0.01em;
}

.mono { font-family: var(--font-mono); }

/* ---------- Layout shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #E8ECEF;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.brand .brand-mark {
  width: 10px; height: 10px;
  background: var(--accent);
  display: inline-block;
  border-radius: 2px;
  transform: rotate(45deg);
}

.company-tag {
  font-size: 0.78rem;
  color: #9AA6B2;
  margin-bottom: 22px;
  word-break: break-word;
}

.role-tag {
  display: inline-block;
  margin-top: 4px;
  color: #6FE3B4;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.role-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #EAF1FB;
  color: #2A5D9C;
}
.role-badge.staff { background: #F5EEFB; color: #6C3C9C; }

.sandbox-banner {
  background: #FFF6E5;
  border: 1px solid #F0D9A0;
  color: #8A6416;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 18px;
}

.qr-box {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-top: 20px;
}
.qr-box img { width: 130px; height: 130px; border-radius: 6px; background: #fff; padding: 6px; border: 1px solid var(--line); }
.qr-box .fields div { margin-bottom: 4px; font-size: 0.85rem; }
.qr-box .fields .mono { word-break: break-all; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #C7CFD6;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--accent); color: #06231A; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: #C7CFD6;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-body);
}
.logout-btn:hover { border-color: var(--stamp); color: #fff; }

.main {
  flex: 1;
  padding: 34px 42px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header p { color: var(--ink-soft); margin: 4px 0 0; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(15,138,95,0.06), transparent 40%),
    var(--paper);
}

.auth-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 1px 2px rgba(27,36,48,0.04);
}
.auth-card.wide { max-width: 620px; }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 4px;
}
.auth-brand .brand-mark {
  width: 11px; height: 11px;
  background: var(--accent);
  display: inline-block;
  border-radius: 2px;
  transform: rotate(45deg);
}
.auth-sub { color: var(--ink-soft); margin-bottom: 26px; font-size: 0.92rem; }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field .hint { font-size: 0.76rem; color: var(--ink-soft); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 70px; }

.form-row { display: flex; gap: 14px; }
.form-row .field { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b3846; }
.btn-accent { background: var(--accent); color: #06231A; }
.btn-accent:hover { background: #0c7550; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: var(--stamp-soft); color: var(--stamp); border: 1px solid #F0C9C5; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-bottom: 18px;
}
.alert-error { background: var(--stamp-soft); color: var(--stamp); border: 1px solid #F0C9C5; }

.form-footer { margin-top: 20px; font-size: 0.86rem; color: var(--ink-soft); text-align: center; }

/* ---------- Cards / stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.stat-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.stat-card .label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
}
.stat-card .value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 6px;
}
.stat-card.accent .value { color: var(--accent); }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 22px;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBFCFD; }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}
.empty-state .btn { margin-top: 14px; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-issued { background: var(--accent-soft); color: var(--accent); }
.badge-cancelled { background: var(--stamp-soft); color: var(--stamp); }
.badge-intra { background: #EAF1FB; color: #2A5D9C; }
.badge-inter { background: #F5EEFB; color: #6C3C9C; }

/* ---------- Invoice document look ---------- */

.invoice-doc {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px;
  position: relative;
}
.invoice-doc::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 20px);
  border-radius: 12px 12px 0 0;
}
.invoice-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 26px;
  flex-wrap: wrap;
  gap: 20px;
}
.invoice-doc-header h2 { margin-bottom: 2px; }
.invoice-doc-header .muted { color: var(--ink-soft); font-size: 0.86rem; }
.invoice-meta { text-align: right; }
.invoice-meta .num { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; }

.bill-to {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 24px;
  max-width: 340px;
}
.bill-to .eyebrow { display: block; margin-bottom: 6px; }

.totals-box {
  margin-left: auto;
  max-width: 320px;
  margin-top: 18px;
}
.totals-box .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.9rem;
}
.totals-box .row.grand {
  border-top: 2px solid var(--ink);
  margin-top: 6px;
  padding-top: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
}

.supply-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 20px;
}

.doc-actions { display: flex; gap: 10px; margin-bottom: 20px; }

.line-items-editor .item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 0.7fr 1fr 0.8fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.item-row label { font-size: 0.7rem; }
.remove-item-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--stamp);
  border-radius: 6px;
  height: 38px;
  width: 38px;
  cursor: pointer;
}

.customer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.customer-avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.activity-list li:last-child { border-bottom: none; }
.activity-time { color: var(--ink-soft); font-family: var(--font-mono); font-size: 0.78rem; white-space: nowrap; }
.activity-action {
  font-weight: 600;
  text-transform: capitalize;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 14px 18px; }
  .company-tag { display: none; }
  .sidebar nav { display: flex; gap: 6px; margin-left: auto; }
  .sidebar-footer { margin-top: 0; padding-top: 0; border: none; }
  .main { padding: 22px; }
  .line-items-editor .item-row { grid-template-columns: 1fr; }
}
