/* Pomi Mobile ERP -- shared theme */

:root {
  --brand-900: #1e1b4b;
  --brand-700: #4338ca;
  --brand-600: #4f46e5;
  --brand-500: #6366f1;
  --brand-100: #e0e7ff;
  --brand-50:  #eef2ff;

  --accent-600: #d97706;
  --accent-500: #f59e0b;
  --accent-100: #fef3c7;

  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;

  --danger-600: #dc2626;
  --danger-100: #fee2e2;
  --success-600: #16a34a;
  --success-100: #dcfce7;

  --surface: #ffffff;
  --bg: var(--slate-50);
  --border: var(--slate-200);
  --text: var(--slate-900);
  --text-muted: var(--slate-500);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);

  --sidebar-w: 250px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em 0; color: var(--slate-900); font-weight: 600; }
p { margin: 0 0 0.75em 0; }

/* ---------------- App shell ---------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand-900);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .mark svg { width: 19px; height: 19px; fill: #fff; }

.sidebar-brand .name { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.2; }
.sidebar-brand .tagline { font-size: 11px; color: #a5b4fc; }

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

.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #818cf8;
  padding: 14px 10px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-size: 13.5px;
  font-weight: 500;
}

.sidebar-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.sidebar-link.active { background: var(--brand-600); color: #fff; }
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }

.sidebar-link.disabled {
  color: #64748b;
  cursor: default;
}
.sidebar-link.disabled:hover { background: none; }

.badge-soon {
  margin-left: auto;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  padding: 2px 6px;
  border-radius: 999px;
}

.badge-soon-light {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--slate-100);
  color: var(--slate-500);
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}

.sidebar-footer .user { color: #fff; font-weight: 600; margin-bottom: 6px; }
.sidebar-footer form { margin: 0; }
.sidebar-footer button {
  background: none;
  border: none;
  color: #a5b4fc;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}
.sidebar-footer button:hover { color: #fff; text-decoration: underline; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 14px;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger svg { width: 22px; height: 22px; }

.content {
  padding: 22px;
  flex: 1;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 35;
}

/* ---------------- Components ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px 20px; }
.card-pad-tight { padding: 12px 16px; }

/* ---------------- New Sale CTA (dashboard) ---------------- */

.new-sale-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-600), var(--brand-900));
  color: #fff;
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.new-sale-cta:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(30, 27, 75, 0.28); text-decoration: none; }
.new-sale-cta-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
.new-sale-cta-icon svg { width: 24px; height: 24px; }
.new-sale-cta-text { flex: 1; min-width: 0; }
.new-sale-cta-title { font-size: 19px; font-weight: 700; }
.new-sale-cta-sub { font-size: 12.5px; opacity: 0.85; margin-top: 2px; }
.new-sale-cta-arrow { flex-shrink: 0; opacity: 0.8; }
.new-sale-cta-arrow svg { width: 20px; height: 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card .icon {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card .icon svg { width: 17px; height: 17px; }

.stat-card .label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--slate-900);
}

.stat-card .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.tone-brand .icon { background: var(--brand-100); color: var(--brand-700); }
.stat-card.tone-accent .icon { background: var(--accent-100); color: var(--accent-600); }
.stat-card.tone-success .icon { background: var(--success-100); color: var(--success-600); }
.stat-card.tone-muted .icon { background: var(--slate-100); color: var(--slate-500); }

.period-tabs {
  display: inline-flex;
  background: var(--slate-100);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.period-tabs a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.period-tabs a:hover { text-decoration: none; color: var(--slate-900); }
.period-tabs a.active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-sm); }

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
  align-items: start;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}

table tbody tr:hover { background: var(--slate-50); }
table tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.pill-red { background: var(--danger-100); color: var(--danger-600); }
.pill-green { background: var(--success-100); color: var(--success-600); }
.pill-muted { background: var(--slate-100); color: var(--slate-600); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 10px;
}

.bar-chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  height: 100%;
  position: relative;
}

.bar-chart .bar {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.bar-chart .bar-col:hover .bar { background: linear-gradient(180deg, var(--accent-500), var(--accent-600)); }

.bar-chart .bar-col .tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: #fff;
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 5px;
  white-space: nowrap;
  margin-bottom: 5px;
  z-index: 5;
}
.bar-chart .bar-col:hover .tooltip { display: block; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: block;
  color: var(--text);
}
.report-card:hover { border-color: var(--brand-500); text-decoration: none; }
.report-card.disabled { opacity: 0.6; cursor: default; }
.report-card.disabled:hover { border-color: var(--border); }

.report-card .icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.report-card .icon svg { width: 18px; height: 18px; }
.report-card h4 { margin-bottom: 4px; font-size: 14.5px; }
.report-card p { font-size: 12.5px; color: var(--text-muted); margin: 0; }

@media (max-width: 900px) {
  .report-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .report-grid { grid-template-columns: 1fr; }
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 10px;
  font-size: 13px;
}

.alert-message {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--success-100);
  color: var(--success-600);
  font-weight: 500;
}
.alert-message.alert-error { background: var(--danger-100); color: var(--danger-600); }

.placeholder-note {
  font-size: 11.5px;
  color: var(--accent-600);
  background: var(--accent-100);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------------- Forms / buttons (used from Dashboard onward) ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); text-decoration: none; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--slate-700); }
.btn-outline:hover { border-color: var(--slate-300); text-decoration: none; }

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}

/* ---------------- Typeahead / billing form ---------------- */

.field-group { position: relative; }

.field-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 5px;
}

.typeahead-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  margin-top: 4px;
}

.typeahead-row {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--slate-100);
}
.typeahead-row:last-child { border-bottom: none; }
.typeahead-row:hover { background: var(--brand-50); }
.typeahead-row .muted { color: var(--text-muted); font-size: 12px; }

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.form-row .field-group { flex: 1; min-width: 200px; }

.totals-box {
  width: 100%;
  max-width: 320px;
  margin-left: auto;
}
.totals-box .trow {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13.5px;
  border-bottom: 1px solid var(--slate-100);
}
.totals-box .trow.grand {
  font-weight: 700;
  font-size: 15px;
  border-bottom: none;
  padding-top: 10px;
}
.totals-box input[type=number] { width: 130px; text-align: right; }

/* Compact mode for the Sale/Billing form -- less vertical space, less scrolling */
.billing-compact .card-pad { padding: 12px 16px; }
.billing-compact .form-row { margin-bottom: 0; gap: 10px; }
.billing-compact .field-group label { margin-bottom: 3px; font-size: 12px; }
.billing-compact table th { padding: 6px 10px; }
.billing-compact table td { padding: 6px 10px; }
.billing-compact .empty-state { padding: 14px; font-size: 12.5px; }
.billing-compact .totals-box .trow { padding: 5px 0; }

/* ---------------- Login page ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, var(--brand-700), var(--brand-900) 60%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.login-card .mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.login-card .mark svg { width: 26px; height: 26px; fill: #fff; }

.login-card h1 { text-align: center; font-size: 18px; margin-bottom: 2px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin-bottom: 22px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate-700); margin-bottom: 5px; }
.field input { width: 100%; }

.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }

.form-error {
  background: var(--danger-100);
  color: var(--danger-600);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-backdrop.open { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
}
