/* ============================================
   SCS Computers — Design tokens
   A technician's tool, not a marketing site.
   Palette: light paper + amber diagnostic accent
   ============================================ */
:root {
  --ink: #0f1720;
  --slate-900: #1b2733;
  --slate-800: #26343f;
  --slate-700: #3a4a56;
  --slate-600: #5c7080;
  --slate-500: #7c8b96;
  --slate-300: #b7c2c9;
  --slate-100: #eef1f2;
  --paper: #f6f7f5;
  --surface: #ffffff;
  --border: #e0ded6;
  --amber: #e8a33d;
  --amber-dark: #c17f1e;
  --circuit-green: #4a9d7f;
  --danger: #c0503f;
  --danger-bg: #fbeae7;
  --success: #3f8a5e;
  --success-bg: #e9f5ee;
  --warn-bg: #fdf3df;
  --warn-text: #8a5a12;
  --info-bg: #e7eef3;
  --info-text: #2c5878;

  --radius: 6px;
  --radius-lg: 10px;
  --font-display: 'Inter', -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Menlo', monospace;

  --shadow-sm: 0 1px 2px rgba(15,23,32,0.06), 0 1px 1px rgba(15,23,32,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,32,0.08);
  --nav-h: 60px;
  --bottom-nav-h: 64px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-display);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ============ TOP BAR ============ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 0 16px;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), var(--amber-dark));
  color: var(--ink); font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
}
.brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}
.brand-name { color: var(--ink); font-weight: 700; font-size: 17px; }

.nav-desktop { display: none; align-items: center; gap: 4px; }
.nav-desktop a {
  color: var(--slate-600); padding: 8px 14px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; transition: all .15s;
}
.nav-desktop a:hover { background: var(--slate-100); color: var(--ink); }
.nav-desktop a.active { background: var(--slate-100); color: var(--amber-dark); }
.nav-desktop a.nav-logout { color: var(--slate-500); margin-left: 8px; }

.hamburger {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 36px; height: 36px; background: none; border: none; cursor: pointer;
}
.hamburger span { display: block; height: 2px; width: 22px; background: var(--ink); border-radius: 2px; }

.nav-mobile {
  display: none; flex-direction: column;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: var(--nav-h); z-index: 99;
}
.nav-mobile.open { display: flex; }
.nav-mobile a {
  padding: 14px 20px; color: var(--ink); font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.nav-mobile a.active { color: var(--amber-dark); }

@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .hamburger { display: none; }
}

/* ============ BOTTOM NAV (mobile) ============ */
.bottom-nav {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface); border-top: 1px solid var(--border);
  height: var(--bottom-nav-h); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--slate-500); font-size: 11px; font-weight: 600;
}
.bottom-nav a.active { color: var(--amber-dark); }
.bn-icon { font-size: 19px; line-height: 1; }
.bn-icon svg { width: 22px; height: 22px; display: block; }
.bn-fab .bn-icon svg { width: 24px; height: 24px; }

.nav-mobile-link { display: flex; align-items: center; gap: 12px; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--slate-500); }
.nav-mobile-link.active .nav-icon { color: var(--amber-dark); }
.bn-fab { position: relative; }
.bn-fab .bn-icon {
  background: var(--amber); color: var(--ink);
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-top: -20px; box-shadow: var(--shadow-md);
  border: 3px solid var(--paper);
}
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

/* ============ MAIN CONTENT ============ */
.main-content { min-height: 100vh; padding: 20px 0 40px; }
.main-content.with-nav { padding-bottom: calc(var(--bottom-nav-h) + 24px); }
@media (min-width: 768px) {
  .main-content.with-nav { padding-bottom: 40px; }
}

/* ============ FLASH MESSAGES ============ */
.flash-container { margin-bottom: 16px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px;
  font-size: 14px; font-weight: 600;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-danger { background: var(--danger-bg); color: var(--danger); }
.flash-warning { background: var(--warn-bg); color: var(--warn-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

/* ============ PAGE HEADER ============ */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; color: var(--ink); }
.page-header .subtitle { color: var(--slate-500); font-size: 13px; margin-top: 2px; }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber-dark);
  margin-bottom: 4px; display: block;
}

/* ============ CARDS ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--slate-500); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #ececec;
}

/* Stat grid on dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px;
  color: var(--ink); position: relative; overflow: hidden;
}
.stat-card .stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: var(--amber-dark); }
.stat-card .stat-label { font-size: 12px; color: var(--slate-500); margin-top: 4px; font-weight: 600; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius); font-weight: 700; font-size: 14px;
  border: none; cursor: pointer; transition: all .15s; font-family: var(--font-display);
  text-align: center; line-height: 1.2;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--slate-800); }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { background: var(--amber-dark); }
.btn-outline { background: var(--surface); color: var(--ink); border: 1.5px solid var(--slate-300); }
.btn-outline:hover { background: var(--slate-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a3402f; }
.btn-success { background: var(--success); color: #fff; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe57; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
label {
  display: block; font-size: 13px; font-weight: 700; color: var(--slate-700);
  margin-bottom: 6px;
}
label .optional { font-weight: 400; color: var(--slate-500); text-transform: none; }
input[type=text], input[type=tel], input[type=number], input[type=password],
input[type=email], textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 15px; font-family: var(--font-display); background: var(--surface); color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--amber-dark); box-shadow: 0 0 0 3px rgba(232,163,61,0.15);
}
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; }
fieldset { border: none; padding: 0; margin: 0 0 20px; }
legend {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--amber-dark); margin-bottom: 12px; padding: 0;
  width: 100%; border-bottom: 1px dashed var(--border); padding-bottom: 8px;
}

/* ============ TABLES / LISTS ============ */
.list-table { width: 100%; border-collapse: collapse; }
.list-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--slate-500); padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.list-table td { padding: 12px 10px; border-bottom: 1px solid #ececec; font-size: 14px; }
.list-table tr:hover { background: var(--slate-100); }
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: table-cell; } }

.record-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; box-shadow: var(--shadow-sm);
}
.record-card:hover { border-color: var(--slate-500); }
.record-id { font-family: var(--font-mono); font-size: 12px; color: var(--slate-500); }
.record-name { font-weight: 700; font-size: 15px; margin: 2px 0; }
.record-meta { font-size: 12.5px; color: var(--slate-500); }
.record-amount { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-open { background: var(--warn-bg); color: var(--warn-text); }
.badge-progress { background: var(--info-bg); color: var(--info-text); }
.badge-closed { background: var(--success-bg); color: var(--success); }
.badge-draft { background: var(--slate-100); color: var(--slate-600); }
.badge-sent { background: var(--info-bg); color: var(--info-text); }
.badge-accepted { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center; padding: 50px 20px; color: var(--slate-500);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.empty-state h3 { color: var(--slate-700); }

/* ============ QUOTATION / SERVICE PRINT VIEW ============ */
.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; flex-wrap: wrap; gap: 16px;
}
.doc-title-block .company { font-size: 20px; font-weight: 800; }
.doc-title-block .tagline { font-size: 12px; color: var(--slate-500); }
.doc-meta { text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--slate-500); }
.doc-meta .doc-no { font-size: 15px; font-weight: 700; color: var(--ink); }

.items-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.items-table th { background: var(--slate-100); color: var(--ink); text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; }
.items-table td { padding: 10px 12px; border-bottom: 1px solid #ececec; font-size: 14px; }
.items-table .num { text-align: right; font-family: var(--font-mono); }
.items-table tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
.total-row .amount { font-size: 18px; color: var(--amber-dark); }

.charge-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 500px) { .charge-grid { grid-template-columns: 1fr 1fr; } }
.charge-item {
  background: var(--paper); border-radius: var(--radius); padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.charge-item .label { font-size: 13px; color: var(--slate-600); font-weight: 600; }
.charge-item .value { font-family: var(--font-mono); font-weight: 700; }
.charge-total {
  background: var(--slate-900); color: #fff; border-radius: var(--radius); padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center; margin-top: 10px;
}
.charge-total .value { font-family: var(--font-mono); font-size: 20px; color: var(--amber); font-weight: 800; }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 4px 20px; }
@media (min-width: 640px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.detail-row { padding: 8px 0; border-bottom: 1px solid #f0efe9; display: flex; justify-content: space-between; gap: 10px; }
.detail-row .k { color: var(--slate-500); font-size: 13px; font-weight: 600; }
.detail-row .v { font-weight: 600; text-align: right; }

/* ============ IMAGE GALLERY ============ */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.img-thumb { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; border: 1px solid var(--border); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb .img-remove {
  position: absolute; top: 4px; right: 4px; background: rgba(15,23,32,0.75); color: #fff;
  border: none; width: 22px; height: 22px; border-radius: 50%; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.img-upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-upload-preview .thumb { width: 70px; height: 70px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); }

/* ============ QUOTE ITEMS BUILDER ============ */
.item-row {
  display: grid; grid-template-columns: 1fr; gap: 8px; align-items: end;
  padding: 12px; background: var(--paper); border-radius: var(--radius); margin-bottom: 8px;
}
@media (min-width: 640px) { .item-row { grid-template-columns: 3fr 1fr 1.3fr auto; gap: 10px; } }
.item-row .remove-item {
  background: none; border: none; color: var(--danger); font-size: 20px; cursor: pointer;
  padding: 8px; justify-self: start;
}
@media (min-width: 640px) { .item-row .remove-item { justify-self: center; } }

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--paper); padding: 20px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 28px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-mark { width: 52px; height: 52px; font-size: 18px; margin: 0 auto 12px; }
.login-brand .brand-logo { height: 52px; margin: 0 auto 12px; display: block; }
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--slate-500); font-size: 13px; margin: 0; }

/* ============ MISC ============ */
.section-divider { height: 1px; background: #ececec; margin: 24px 0; }
.text-muted { color: var(--slate-500); }
.mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,32,0.6); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-md);
}

/* ============ PRINT ============ */
@media print {
  .no-print, .topbar, .nav-mobile, .bottom-nav, .btn-group, .flash-container { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .main-content { padding: 0; }
}