/* ============================================================
   AquaPay Portal - Global Stylesheet
   Theme: Black & White, Human Design
   No gradients. No color. Weight + space = hierarchy.
   ============================================================ */

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

:root {
  --black:      #000000;
  --white:      #ffffff;
  --gray-50:    #fafafa;
  --gray-100:   #f4f4f4;
  --gray-200:   #e8e8e8;
  --gray-300:   #d0d0d0;
  --gray-400:   #a8a8a8;
  --gray-500:   #787878;
  --gray-600:   #505050;
  --gray-700:   #383838;
  --gray-800:   #202020;
  --gray-900:   #121212;

  --text-primary:   var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted:     var(--gray-400);
  --text-inverse:   var(--white);

  --border:     var(--gray-200);
  --border-strong: var(--gray-400);

  --bg-page:    var(--gray-50);
  --bg-surface: var(--white);
  --bg-raised:  var(--white);

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;

  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --sidebar-w:  240px;
  --topbar-h:   56px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
}

html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 1.6rem;  font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.3;  }
h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.35; }
h4 { font-size: .9rem;   font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
p  { line-height: 1.7; color: var(--text-secondary); }
a  { color: var(--black); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--gray-600); }
small { font-size: .8rem; color: var(--text-muted); }
code  { font-family: var(--font-mono); font-size: .85em; background: var(--gray-100); padding: 1px 5px; border-radius: 3px; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-content { padding: 28px; flex: 1; }

/* ── Sidebar ── */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--white);
  text-decoration: none;
}
.sidebar-logo svg { flex-shrink: 0; }
.nav-group { padding: 16px 0 8px; }
.nav-group-label {
  padding: 0 16px 6px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .12s, color .12s;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-active { background: var(--white) !important; color: var(--black) !important; }
.nav-active svg { stroke: var(--black) !important; }
.nav-item svg { stroke: rgba(255,255,255,.65); flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
  color: rgba(255,255,255,.35);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: rgba(255,255,255,.65);
}
.sidebar-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}

/* ── Topbar ── */
.topbar-title { font-weight: 600; font-size: 1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header-left h1 { margin-bottom: 4px; }
.page-header-left p { margin: 0; font-size: .9rem; }

/* ── Cards / panels ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.stat-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--black);
}
.stat-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Dashboard grid ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dash-grid .span-2 { grid-column: 1 / -1; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.td-mono { font-family: var(--font-mono); font-size: .8rem; }

/* ── Badges / tags ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border: 1px solid;
}
.badge-active  { background: #f0f0f0; color: #202020; border-color: #d0d0d0; }
.badge-inactive { background: #fafafa; color: #787878; border-color: #e0e0e0; }
.badge-pending { background: #f7f7f0; color: #505020; border-color: #d8d8b0; }
.badge-success { background: #f0f7f0; color: #205020; border-color: #b0d0b0; }
.badge-error   { background: #f7f0f0; color: #502020; border-color: #d0b0b0; }
.badge-super   { background: #000;    color: #fff;    border-color: #000;    }

/* ── Status dot ── */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-on  { background: var(--gray-800); }
.dot-off { background: var(--gray-300); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row { margin-bottom: 20px; }
.form-row.full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}
label .optional { font-weight: 400; color: var(--text-muted); }
.field-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.5;
}
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=tel],
select,
textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
input[disabled], select[disabled], textarea[disabled] {
  background: var(--gray-100);
  color: var(--text-muted);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 90px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23505050' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input-group { display: flex; }
.input-group input { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group .input-addon { padding: 9px 12px; background: var(--gray-100); border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; font-size: .85rem; color: var(--text-secondary); white-space: nowrap; display: flex; align-items: center; }
.form-section { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.form-section-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: .88rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(.99); }
.btn svg { flex-shrink: 0; }
.btn-primary   { background: var(--black); color: var(--white); }
.btn-primary:hover { background: var(--gray-800); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--black); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-100); color: var(--black); }
.btn-danger    { background: var(--white); color: #802020; border-color: #d0b0b0; }
.btn-danger:hover { background: #f7f0f0; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-group { display: flex; gap: 8px; align-items: center; }

/* ── Alerts / flashes ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: .88rem;
  margin-bottom: 20px;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f4faf4; border-color: #c0d8c0; color: #2a502a; }
.alert-error   { background: #faf4f4; border-color: #d8c0c0; color: #502a2a; }
.alert-warning { background: #faf8f0; border-color: #d8d0a0; color: #504020; }
.alert-info    { background: #f4f4fa; border-color: #c0c0d8; color: #2a2a50; }

/* ── Dividers & separators ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.section-sep { border: none; border-top: 2px solid var(--border); margin: 28px 0; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
}
.empty-state svg { color: var(--gray-300); }
.empty-state h3 { color: var(--gray-500); font-weight: 500; }
.empty-state p  { max-width: 280px; font-size: .85rem; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 16px;
}
.page-link {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.page-link:hover { background: var(--gray-100); color: var(--black); }
.page-link.active { background: var(--black); color: var(--white); border-color: var(--black); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Detail rows (show pages) ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.detail-row {
  padding: 13px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.detail-row dd { font-size: .92rem; color: var(--text-primary); }

/* ── Dispenser list ── */
.dispenser-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dispenser-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-800);
  margin-top: 7px;
  flex-shrink: 0;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-size: .88rem; font-weight: 500; }
.timeline-meta  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}
.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 28px;
  justify-content: center;
}

/* ── Misc ── */
.mono   { font-family: var(--font-mono); }
.muted  { color: var(--text-muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.dispensers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

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