/* ── CSS Variables (dark green theme) ──────────────────────────────────── */
:root {
  --bg:            #0f2218;
  --surface:       #1a3a28;
  --surface-raised:#224533;
  --border:        #2d5a3d;
  --border-subtle: #1f4733;
  --text:          #e8f5e9;
  --text-muted:    #81c784;
  --text-faint:    #4a7c5a;
  --accent:        #66bb6a;
  --accent-dark:   #388e3c;
  --accent-hover:  #57a05b;
  --danger:        #ef5350;
  --danger-dark:   #c62828;
  --warning:       #ffa726;
  --info:          #42a5f5;
  --sidebar-w:     230px;
  --header-h:      56px;
  --radius:        6px;
  --shadow:        0 2px 8px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 14px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Layout ────────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
#sidebar-logo span { font-size: 16px; font-weight: 700; color: var(--accent); letter-spacing: 0.3px; }
#sidebar-logo small { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; letter-spacing: 0.5px; }
#nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: var(--radius);
  margin: 2px 8px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-raised); color: var(--text); }
.nav-item.active { background: var(--accent-dark); color: var(--text); }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 16px; }
.nav-item .nav-label { font-size: 13.5px; font-weight: 500; }
.nav-section-label {
  padding: 16px 18px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: normal;
  overflow-wrap: break-word;
}
.nav-section-label:first-child { padding-top: 6px; }
#sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
#user-info { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
#btn-oms-home, #btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  margin-bottom: 6px;
}
#btn-oms-home:hover, #btn-logout:hover { background: var(--surface-raised); color: var(--text); }

/* Main area */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
#page-title { font-size: 16px; font-weight: 600; flex: 1; }
#content { flex: 1; overflow-y: auto; padding: 20px; }

/* ── Pages ─────────────────────────────────────────────────────────────── */
.page { display: block; }
.page.hidden { display: none; }

/* ── OMS landing page ──────────────────────────────────────────────────── */
#landing-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
#landing-screen.hidden { display: none; }
.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
}
.landing-logo { height: 56px; margin-bottom: 14px; }
.landing-card h1 { font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.landing-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.landing-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.landing-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 10px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.landing-tile:hover { background: var(--accent-dark); border-color: var(--accent); text-decoration: none; }
.landing-tile-icon { font-size: 28px; }
.landing-tile-label { font-size: 12.5px; font-weight: 600; line-height: 1.3; }

/* ── Login screen ───────────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#login-screen.hidden { display: none; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.login-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
#btn-login {
  width: 100%;
  background: var(--accent-dark);
  color: var(--text);
  border: none;
  padding: 10px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
#btn-login:hover { background: var(--accent-hover); }

/* ── Cards / stat boxes ─────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--surface-raised);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-subtle); }
tbody tr:hover { background: var(--surface); }
tbody td { padding: 9px 12px; vertical-align: middle; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-in  { background: rgba(102,187,106,0.2); color: var(--accent); }
.badge-out { background: rgba(66,165,245,0.2);  color: var(--info); }
.badge-other { background: rgba(255,167,38,0.2); color: var(--warning); }
.badge-warn  { background: var(--warning); color: #000; }
.badge-f { background: rgba(102,187,106,0.15); color: var(--accent); }
.badge-c { background: rgba(255,167,38,0.15);  color: var(--warning); }
.badge-r { background: rgba(239,83,80,0.15);   color: var(--danger); }

/* ── Filters bar ────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group input,
.filter-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  min-width: 140px;
}
.filter-group input:focus,
.filter-group select:focus { outline: 1px solid var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: none;
  font-weight: 600; font-size: 13px; transition: background 0.15s;
}
.btn-primary { background: var(--accent-dark); color: var(--text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger-dark); color: var(--text); }
.btn-danger:hover { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Section headings ───────────────────────────────────────────────────── */
.section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.section-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }

/* ── Import page ────────────────────────────────────────────────────────── */
.import-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
}
.import-zone:hover, .import-zone.drag-over { border-color: var(--accent); background: rgba(102,187,106,0.05); }
.import-zone p { color: var(--text-muted); margin-top: 8px; font-size: 13px; }
.import-zone .import-icon { font-size: 36px; }

.progress-wrap { margin: 16px 0; }
.progress-bar-outer { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar-inner { background: var(--accent); height: 100%; border-radius: 4px; transition: width 0.2s; width: 0%; }
.progress-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.preview-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.preview-box .preview-stat { display: inline-block; margin-right: 24px; }
.preview-box .preview-stat strong { color: var(--accent); font-size: 20px; }
.preview-box .preview-stat span { font-size: 12px; color: var(--text-muted); display: block; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn {
  padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-weight: 600; font-size: 13px; cursor: pointer;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500; max-width: 340px;
  animation: slideIn 0.2s ease;
}
.toast-success { background: var(--accent-dark); color: var(--text); }
.toast-error   { background: var(--danger-dark);  color: var(--text); }
.toast-info    { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Modal ──────────────────────────────────────────────────────────────── */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 340px;
  max-width: 520px;
  box-shadow: var(--shadow);
}
.modal h2 { font-size: 16px; margin-bottom: 12px; }
.modal-body { margin-bottom: 20px; font-size: 13px; color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.tonnage { font-variant-numeric: tabular-nums; }

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dash-period-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.dash-period-bar .btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.flag-banner {
  background: rgba(255,167,38,0.15);
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}

.kpi-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.kpi-hero     { grid-template-columns: 1fr 1fr; }
.kpi-contract { grid-template-columns: repeat(4, 1fr); }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.kpi-card.kpi-in  { border-left: 4px solid var(--accent); }
.kpi-card.kpi-out { border-left: 4px solid var(--info); }
.kpi-card.kpi-contract-card { border-left: 4px solid var(--warning); }

.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi-value-sm { font-size: 22px; }
.kpi-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; height: 260px; margin-bottom: 8px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.dash-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  #sidebar { display: none; }
}
