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

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

:root {
  --navy:        #1a1f36;
  --navy-2:      #252b45;
  --indigo:      #5c6bc0;
  --indigo-lt:   #7986cb;
  --indigo-pale: #e8eaf6;
  --violet:      #7c4dff;
  --violet-lt:   #b39ddb;
  --violet-pale: #ede7f6;
  --blue:        #448aff;
  --blue-pale:   #e3f2fd;
  --white:       #ffffff;
  --surface:     #f7f8fc;
  --surface-2:   #eef0f8;
  --border:      rgba(92,107,192,0.15);
  --border-2:    rgba(92,107,192,0.28);
  --text:        #1a1f36;
  --text-2:      #4a5568;
  --text-3:      #8896b3;
  --green:       #00c896;
  --green-bg:    #e0faf3;
  --red:         #f44336;
  --red-bg:      #fce4ec;
  --amber:       #ffab40;
  --amber-bg:    #fff8e1;
  --shadow-sm:   0 2px 8px rgba(92,107,192,0.08);
  --shadow-md:   0 8px 32px rgba(92,107,192,0.12);
  --shadow-lg:   0 20px 60px rgba(92,107,192,0.16);
  --r-sm:        8px;
  --r:           12px;
  --r-lg:        18px;
  --r-xl:        24px;
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'DM Mono', monospace;
  --nav-h:       64px;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── TOPBAR ── */
.topbar {
  background: var(--navy);
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--violet) 0%, var(--indigo) 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.brand-icon svg { width: 18px; height: 18px; fill: white; }
.brand-name { font-size: 15px; font-weight: 600; color: white; letter-spacing: -0.02em; }
.brand-sub { font-size: 10px; color: rgba(255,255,255,0.35); font-weight: 300; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 13px; color: rgba(255,255,255,0.6); }
.btn-logout {
  font-size: 12px; color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 14px; border-radius: var(--r-sm); cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover { color: white; background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); }

/* ── PAGE ── */
.page { padding-top: 0; min-height: 100vh; }
.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px; }

/* ── PAGE HEADER ── */
.page-head { margin-bottom: 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.page-head .sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── CARD ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── FORM ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width:640px) { .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: 0.01em; }

input[type=text], input[type=tel], input[type=number],
input[type=email], input[type=date], input[type=password],
select, textarea {
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px; font-family: var(--font);
  background: var(--white); color: var(--text);
  width: 100%; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(92,107,192,0.12);
}
input::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 80px; }
input.valid   { border-color: var(--green) !important; }
input.invalid { border-color: var(--red) !important; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--white); color: var(--text-2);
  font-size: 13px; font-family: var(--font); font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-pale); }
.btn-primary {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  color: white; border-color: transparent;
  box-shadow: 0 4px 14px rgba(92,107,192,0.35);
}
.btn-primary:hover { opacity: .9; color: white; box-shadow: 0 6px 20px rgba(92,107,192,0.45); transform: translateY(-1px); }
.btn-success { background: var(--green); color: white; border-color: transparent; }
.btn-success:hover { opacity: .9; color: white; }
.btn-danger  { background: var(--red);   color: white; border-color: transparent; }
.btn-danger:hover  { opacity: .9; color: white; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: none; border-color: transparent; color: var(--indigo); padding: 5px 10px; }
.btn-ghost:hover { background: var(--indigo-pale); }
.back-btn { background: var(--indigo-pale); color: var(--indigo); border-color: transparent; }

/* ── DASHBOARD STATS ── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--indigo), var(--violet));
}
.stat-card.green::before  { background: linear-gradient(90deg, var(--green), #26d0a0); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--red), #ff6090); }
.stat-card.amber::before  { background: linear-gradient(90deg, var(--amber), #ffd740); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 600; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }
.stat-value.amber { color: var(--amber); }

/* ── MENU CARDS ── */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px,1fr)); gap: 12px; }
.menu-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px 16px; text-align: center;
  cursor: pointer; box-shadow: var(--shadow-sm); transition: all 0.2s;
}
.menu-card:hover { border-color: var(--indigo); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.menu-card:hover .menu-icon { background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%); }
.menu-card:hover .menu-icon svg { stroke: white; }
.menu-icon {
  width: 42px; height: 42px; border-radius: var(--r);
  background: var(--indigo-pale); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; transition: all 0.2s;
}
.menu-icon svg { width: 20px; height: 20px; stroke: var(--indigo); fill: none; stroke-width: 1.8; transition: all 0.2s; }
.menu-card h3 { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.menu-card p  { font-size: 11px; color: var(--text-3); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--surface);
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover td { background: var(--indigo-pale); }
tbody td { padding: 11px 14px; color: var(--text-2); vertical-align: middle; }
.td-actions { display: flex; gap: 6px; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--indigo); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 20px; letter-spacing: 0.02em;
}
.badge-green  { background: var(--green-bg);   color: #00916e; }
.badge-red    { background: var(--red-bg);      color: #c62828; }
.badge-amber  { background: var(--amber-bg);    color: #e65100; }
.badge-blue   { background: var(--indigo-pale); color: var(--indigo); }
.badge-violet { background: var(--violet-pale); color: var(--violet); }
.badge-gray   { background: var(--surface-2);   color: var(--text-3); }

/* ── SEARCH ── */
.search-bar { position: relative; margin-bottom: 16px; }
.search-bar input { padding-left: 36px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ── AUTOCOMPLETE ── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border-2);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  z-index: 200; max-height: 220px; overflow-y: auto;
}
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border); transition: background 0.1s; color: var(--text-2);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--indigo-pale); color: var(--indigo); }
.autocomplete-item small { display: block; color: var(--text-3); font-size: 11px; margin-top: 1px; }

/* ── SERVICE TOGGLE ── */
.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  padding: 8px 16px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--white); color: var(--text-2);
  transition: all 0.15s; user-select: none;
}
.check-item:hover { border-color: var(--indigo); background: var(--indigo-pale); color: var(--indigo); }
.check-item.active {
  border-color: var(--indigo);
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  color: white; box-shadow: 0 4px 12px rgba(92,107,192,0.3);
}
.check-item svg { flex-shrink: 0; }

/* ── BILL BOX ── */
.bill-box { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.bill-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.bill-row:last-child { border-bottom: none; font-weight: 600; color: var(--text); font-size: 14px; background: var(--indigo-pale); }
.bill-row span:last-child { font-family: var(--mono); }

/* ── TOTAL DISPLAY ── */
.total-display {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  border-radius: var(--r); padding: 18px 22px;
  display: flex; justify-content: space-between; align-items: center; margin-top: 14px;
  box-shadow: var(--shadow-md);
}
.td-label { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.08em; }
.td-sub   { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 2px; }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(26,31,54,0.6); z-index: 2000; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: var(--r-xl); padding: 28px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); animation: popIn .2s ease; max-height: 90vh; overflow-y: auto; border: 1px solid var(--border); }
.modal-box.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h2 { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close { background: var(--surface-2); border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; color: var(--text-3); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
@keyframes popIn { from { transform: scale(.94) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* ── ALERT ROWS ── */
.alert-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); margin-bottom: 8px; font-size: 13px; }
.alert-row.red    { background: var(--red-bg);    border-left: 3px solid var(--red); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.alert-row.amber  { background: var(--amber-bg);  border-left: 3px solid var(--amber); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.alert-row.blue   { background: var(--indigo-pale); border-left: 3px solid var(--indigo); border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ── TAGS ── */
.tag { display: inline-flex; align-items: center; gap: 5px; background: var(--indigo-pale); color: var(--indigo); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.tags-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── VEHICLE INFO ── */
.vehicle-info-panel { background: var(--indigo-pale); border: 1px solid rgba(92,107,192,0.2); border-radius: var(--r); padding: 14px 16px; margin-top: 12px; }
.vehicle-info-row { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; }
.vehicle-info-row strong { color: var(--text); font-weight: 600; }
.vehicle-info-row label { font-size: 11px; color: var(--text-3); display: block; margin-bottom: 1px; }
.nitrogen-card-panel { background: var(--green-bg); border: 1px solid rgba(0,200,150,0.25); border-radius: var(--r-sm); padding: 10px 14px; margin-top: 8px; font-size: 13px; color: #00916e; }

/* ── LOGIN ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, #2d1b69 50%, var(--navy-2) 100%); }
.login-card { background: rgba(255,255,255,0.95); border-radius: var(--r-xl); padding: 42px 38px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,0.3); }
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .logo-mark { width: 48px; height: 48px; background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; box-shadow: 0 8px 24px rgba(92,107,192,0.4); }
.login-logo .logo-mark svg { width: 26px; height: 26px; fill: white; }
.login-logo h1 { font-size: 18px; font-weight: 600; color: var(--text); }
.login-logo p { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ── VALIDATION ── */
.validation-msg { font-size: 11px; color: var(--red); margin-top: 3px; display: none; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.rim-price-hint { font-size: 11px; color: var(--indigo); margin-top: 3px; font-family: var(--mono); }

/* ── NITROGEN OWNER PANEL ── */
.nitrogen-owner-panel { background: var(--green-bg); border: 1.5px solid rgba(0,200,150,0.3); border-radius: var(--r); padding: 14px 16px; margin-top: 10px; }
.nitrogen-owner-panel .no-title { font-size: 11px; font-weight: 600; color: #00916e; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.nitrogen-owner-panel .no-row { display: flex; gap: 20px; font-size: 13px; flex-wrap: wrap; }
.nitrogen-owner-panel .no-row strong { color: var(--text); font-weight: 600; }
.history-btn { font-size: 12px; font-weight: 500; color: var(--indigo); background: var(--indigo-pale); border: 1px solid rgba(92,107,192,0.2); padding: 5px 14px; border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s; }
.history-btn:hover { background: var(--indigo); color: white; }

/* ── UTILS ── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-small  { font-size: 12px; color: var(--text-3); }
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.fw-600 { font-weight: 600; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── RESPONSIVE ── */
@media(max-width:768px) {
  .topbar { padding: 0 18px; }
  .container { padding: 20px 16px; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .menu-grid { grid-template-columns: 1fr 1fr; }
}
@media(max-width:480px) {
  .dash-grid { grid-template-columns: 1fr; }
}
/* ── FOOTER ── */
.app-footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  border-top: 2px solid var(--indigo);
  margin-top: 24px;
  letter-spacing: 0.06em;
}
.app-footer span {
  color: var(--amber);
  font-weight: 700;
}