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

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;

  --navy:        #1e293b;
  --navy-2:      #0f172a;
  --navy-3:      #334155;
  --copper:      #d97706;
  --copper-2:    #b45309;

  --blue:        #3b82f6;
  --teal:        #0891b2;
  --green:       #059669;
  --amber:       #d97706;
  --red:         #dc2626;
  --purple:      #7c3aed;

  --text:        #1e293b;
  --text-2:      #475569;
  --text-3:      #94a3b8;

  --success-bg:  #ecfdf5;
  --success-txt: #065f46;
  --danger-bg:   #fef2f2;
  --danger-txt:  #991b1b;
  --warn-bg:     #fffbeb;
  --warn-txt:    #92400e;

  --radius:      10px;
  --radius-lg:   14px;
  --radius-sm:   7px;
  --shadow-sm:   0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:      0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:   0 10px 40px rgba(15,23,42,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { font-family: 'Sora', 'Inter', sans-serif; font-weight: 700; color: var(--navy-2); line-height: 1.2; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: 'JetBrains Mono', monospace; font-weight: 500; }

/* ── App shell ──────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy-2);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar .brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar .brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--copper), #f59e0b);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 700; font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.sidebar .brand-text { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 17px; color: #fff; }
.sidebar .brand-text span { color: var(--copper); }

.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: #475569; padding: 12px 12px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: #94a3b8; font-size: 13.5px; font-weight: 500;
  text-decoration: none; margin-bottom: 1px;
  transition: all .15s; cursor: pointer;
  position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; text-decoration: none; }
.nav-link.active {
  background: rgba(217,119,6,.12);
  color: #fbbf24;
}
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--copper);
}
.nav-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  background: rgba(255,255,255,.07);
}
.nav-link.active .nav-icon { background: rgba(217,119,6,.2); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11.5px; color: #64748b; }
.logout-link { display: block; margin-top: 8px; font-size: 12.5px; color: #64748b; padding: 6px 8px; border-radius: 6px; text-decoration: none; }
.logout-link:hover { background: rgba(220,38,38,.15); color: #fca5a5; text-decoration: none; }

/* ── Main content ───────────────────────────────────────── */
.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--navy-2); font-family: 'Sora', sans-serif; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-badge { font-size: 12.5px; color: var(--text-2); background: var(--bg); padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); }

.content { padding: 26px 28px 48px; flex: 1; }

/* ── Flash messages ─────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.flash.success { background: var(--success-bg); color: var(--success-txt); border: 1px solid #a7f3d0; }
.flash.error   { background: var(--danger-bg);  color: var(--danger-txt);  border: 1px solid #fecaca; }

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  transition: box-shadow .2s, transform .2s;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.kpi-left {}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 600; color: var(--navy-2); }
.kpi-sub   { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.kpi-icon-box {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.ikb-blue   { background: linear-gradient(135deg,#dbeafe,#bfdbfe); }
.ikb-teal   { background: linear-gradient(135deg,#cffafe,#a5f3fc); }
.ikb-amber  { background: linear-gradient(135deg,#fef3c7,#fde68a); }
.ikb-red    { background: linear-gradient(135deg,#fee2e2,#fecaca); }
.ikb-orange { background: linear-gradient(135deg,#ffedd5,#fed7aa); }
.ikb-purple { background: linear-gradient(135deg,#ede9fe,#ddd6fe); }
.ikb-green  { background: linear-gradient(135deg,#d1fae5,#a7f3d0); }

/* ── Panels ─────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 20px; overflow: hidden; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-head h3 { font-size: 14.5px; font-weight: 700; color: var(--navy-2); margin: 0; }
.panel-body { padding: 20px; }

/* ── Tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 16px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.text-right { text-align: right; }
.text-muted { color: var(--text-3); }
.low-stock td:first-child { border-left: 3px solid var(--amber); }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; gap: 4px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-success { background: var(--success-bg); color: var(--success-txt); }
.badge-success::before { background: var(--green); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-txt); }
.badge-danger::before  { background: var(--red); }
.badge-warning { background: var(--warn-bg);    color: var(--warn-txt); }
.badge-warning::before { background: var(--amber); }
.badge-muted   { background: #f1f5f9; color: var(--text-3); }
.badge-muted::before   { background: #94a3b8; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: 'Inter', sans-serif; text-decoration: none;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.btn-primary:hover { background: var(--navy); }
.btn-accent  { background: var(--copper); color: #fff; border-color: var(--copper); box-shadow: 0 2px 8px rgba(217,119,6,.3); }
.btn-accent:hover  { background: var(--copper-2); }
.btn-outline { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger  { background: var(--danger-bg); color: var(--danger-txt); border-color: #fecaca; }
.btn-danger:hover  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 5px; }

/* ── Forms ───────────────────────────────────────────────── */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

input[type=text], input[type=number], input[type=password], input[type=date],
input[type=datetime-local], input[type=email], input[type=tel],
input[type=month], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: 'Inter', sans-serif;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.help-text { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f2247 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: var(--radius-lg); padding: 36px 32px;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand-icon { width: 42px; height: 42px; background: linear-gradient(135deg,var(--copper),#f59e0b); border-radius: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Sora',sans-serif; font-weight: 700; font-size: 18px; color: #fff; }
.login-brand-name { font-family: 'Sora',sans-serif; font-weight: 700; font-size: 22px; }
.login-brand-name span { color: var(--copper); }
.login-subtitle { font-size: 13.5px; color: var(--text-3); margin-bottom: 26px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14.5px; }

/* ── Invoice print ───────────────────────────────────────── */
.invoice-box { max-width: 800px; margin: 0 auto; background: #fff; padding: 36px; }
.invoice-box .inv-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--navy-2); padding-bottom: 20px; margin-bottom: 24px; }
.invoice-box .inv-head h2 { font-size: 22px; }
.invoice-box table thead th { background: var(--navy-2); color: #fff; }
.invoice-box .totals { width: 300px; margin-left: auto; margin-top: 16px; }
.invoice-box .totals div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.invoice-box .totals div:last-child { border-bottom: none; }
.invoice-box .totals .grand { border-top: 2px solid var(--navy-2); border-bottom: none; font-weight: 700; font-size: 16px; padding-top: 10px; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state .es-icon { font-size: 38px; margin-bottom: 12px; opacity: .5; }
.empty-state h4 { color: var(--text-2); margin-bottom: 6px; font-size: 15px; }
.empty-state p  { font-size: 13.5px; }

/* ── Dashboard specific ──────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.quick-action-list { display: flex; flex-direction: column; gap: 8px; }
.qa-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  font-weight: 500; font-size: 13.5px;
  transition: all .15s;
}
.qa-item:hover { background: var(--navy-2); color: #fff; border-color: var(--navy-2); text-decoration: none; }
.qa-item .qa-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }

/* ── Misc utilities ──────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .dash-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
