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

:root {
  --bg:           #080C10;
  --surface:      #0F1620;
  --surface-2:    #172030;
  --border:       #1E2D3D;
  --border-hi:    #2A3F55;
  --accent:       #F5A623;
  --accent-dim:   rgba(245,166,35,0.14);
  --text:         #C8D8E8;
  --text-muted:   #4E6A84;
  --text-bright:  #EFF6FF;
  --green:        #27C56B;
  --yellow:       #F5A623;
  --red:          #E8394A;
  --blue:         #2E9BF0;
  --green-dim:    rgba(39,197,107,0.12);
  --yellow-dim:   rgba(245,166,35,0.12);
  --red-dim:      rgba(232,57,74,0.12);
  --blue-dim:     rgba(46,155,240,0.12);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  overflow: hidden;
}

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 30px 36px;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 7px;
}

.logo-mark span { color: var(--accent); }

.logo-sub {
  font-size: 9.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 3px;
}

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

.nav-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  padding: 4px 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.13s ease;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(245,166,35,0.2);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-chip { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 30px; height: 30px;
  background: var(--accent-dim);
  border: 1px solid rgba(245,166,35,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Barlow Condensed', sans-serif;
  flex-shrink: 0;
}

.user-info .name  { font-size: 12px; font-weight: 500; color: var(--text); }
.user-info .role  { font-size: 10px; color: var(--text-muted); font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; }
.logout-link      { display: block; margin-top: 10px; font-size: 11px; color: var(--text-muted); text-decoration: none; transition: color 0.13s; }
.logout-link:hover { color: var(--red); }

/* ── Page header ── */
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-bright);
  line-height: 1;
}

.page-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.04em;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color 0.13s; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.35; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

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

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.green::after  { background: var(--green); }
.stat-card.yellow::after { background: var(--yellow); }
.stat-card.red::after    { background: var(--red); }
.stat-card.blue::after   { background: var(--blue); }

.stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1;
}

.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Site cards ── */
.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none;
  display: block;
  transition: all 0.13s ease;
  cursor: pointer;
}

.site-card:hover {
  border-color: var(--border-hi);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.site-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.site-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-bright);
  line-height: 1.2;
}

.site-address { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-family: 'IBM Plex Mono', monospace; }

.type-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-transportation { background: var(--blue-dim);   color: var(--blue);   border: 1px solid rgba(46,155,240,0.3); }
.badge-construction   { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,166,35,0.3); }
.badge-farm           { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(39,197,107,0.3); }
.badge-school         { background: rgba(167,139,250,0.12); color: #A78BFA; border: 1px solid rgba(167,139,250,0.3); }
.badge-other          { background: var(--surface-2);  color: var(--text-muted); border: 1px solid var(--border); }

.site-tank-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

.tank-pill {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 3px 9px;
  border-radius: 3px;
}

.tank-pill.ok   { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(39,197,107,0.3); }
.tank-pill.warn { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,166,35,0.3); }
.tank-pill.crit { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(232,57,74,0.3); }

/* ── Tank gauge cards ── */
.tank-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  border-left-width: 3px;
}

.tank-card.ok   { border-left-color: var(--green); }
.tank-card.warn { border-left-color: var(--yellow); }
.tank-card.crit { border-left-color: var(--red); }

.tank-card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}

.tank-type-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 2px;
}

.gauge-wrap { display: flex; justify-content: center; margin: 6px 0 2px; }

.tank-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.meta-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.meta-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text);
  margin-top: 2px;
}

.tank-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ── Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 4px;
}

.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.status-badge.ok   { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(39,197,107,0.3); }
.status-badge.ok::before   { background: var(--green); }
.status-badge.warn { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,166,35,0.3); }
.status-badge.warn::before { background: var(--yellow); }
.status-badge.crit { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(232,57,74,0.3); }
.status-badge.crit::before { background: var(--red); animation: blink 1.2s infinite; }

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.2; } }

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(30,45,61,0.4);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(23,32,48,0.6); }

/* ── Alerts ── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: var(--surface-2); }

.alert-icon {
  width: 36px; height: 36px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.alert-icon.crit { background: var(--red-dim); }
.alert-icon.warn { background: var(--yellow-dim); }

.alert-title { font-size: 13px; font-weight: 500; color: var(--text-bright); }
.alert-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-family: 'IBM Plex Mono', monospace; }
.alert-ack   { margin-left: auto; flex-shrink: 0; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  outline: none;
  transition: border-color 0.13s;
  appearance: none;
}

.form-control:focus { border-color: var(--accent); }
.form-control option { background: var(--surface-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all 0.13s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #e8971f; }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }

.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(232,57,74,0.3); }
.btn-danger:hover { background: rgba(232,57,74,0.22); }

.btn-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(39,197,107,0.3); }
.btn-green:hover { background: rgba(39,197,107,0.22); }

.btn-sm { padding: 5px 12px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(245,166,35,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 42px 40px;
  width: 100%;
  max-width: 380px;
  position: relative;
  z-index: 1;
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark { font-size: 28px; justify-content: center; }
.login-logo .logo-sub { text-align: center; margin-top: 4px; }

.login-title { font-family: 'Barlow Condensed', sans-serif; font-size: 19px; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 24px; font-family: 'IBM Plex Mono', monospace; }

.demo-hint {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.7;
}

.error-flash { background: var(--red-dim); border: 1px solid rgba(232,57,74,0.3); color: var(--red); padding: 9px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 16px; }
.success-flash { background: var(--green-dim); border: 1px solid rgba(39,197,107,0.3); color: var(--green); padding: 9px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 16px; }

/* ── Charts ── */
.chart-container { position: relative; height: 260px; }
.chart-container-sm { position: relative; height: 180px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 28px;
  width: 500px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  z-index: 1000;
}

.modal-title { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 600; color: var(--text-bright); margin-bottom: 20px; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }

/* ── Misc utilities ── */
.section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.text-green  { color: var(--green) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-red    { color: var(--red) !important; }
.text-muted  { color: var(--text-muted) !important; }
.text-bright { color: var(--text-bright) !important; }
.text-mono   { font-family: 'IBM Plex Mono', monospace; }
.text-condensed { font-family: 'Barlow Condensed', sans-serif; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 900px)  { .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 700px)  {
  .sidebar { width: 52px; }
  .sidebar .nav-item span, .logo-sub, .user-info, .sidebar-footer .logout-link { display: none; }
  .main-content { margin-left: 52px; padding: 18px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
