/* ============================================================
   ALGLink Admin — Modern Design System
   Palette matches /nds/status.php and /nds/fas.php (dark theme)
   Self-contained: no external fonts, no CDN, no framework.
   ============================================================ */

:root {
  --bg:          #0d1b2a;
  --bg-elev-1:   #12233a;
  --bg-elev-2:   #16283f;
  --card:        #16213e;
  --card-hover:  #1b2a4a;
  --border:      #22304a;
  --border-soft: #1a2740;
  --text:        #e7ecf3;
  --text-dim:    #b6c2d1;
  --text-muted:  #8aa0b5;
  --accent:      #96c11f;
  --accent-dim:  #7ba019;
  --accent-soft: rgba(150, 193, 31, 0.12);
  --danger:      #ef5c5c;
  --warn:        #f0b429;
  --info:        #5aa8ff;
  --success:     #2ecc71;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.25);
  --shadow:      0 6px 18px rgba(0,0,0,0.35);
  --sidebar-w:   240px;
  --header-h:    56px;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); }

h1, h2, h3, h4, h5 { font-weight: 600; color: var(--text); margin: 0 0 0.6em; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }

hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

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

.alg-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elev-1);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 10;
}

.alg-sidebar-brand {
  padding: 2px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.alg-sidebar-brand .brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}
.alg-sidebar-brand .brand-text {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
  color: var(--text);
}
.alg-sidebar-brand .brand-sub {
  color: var(--text-muted);
  font-size: 11px;
  display: block;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.alg-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}
.alg-nav-group-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 14px 20px 6px;
  font-weight: 600;
}
.alg-nav li { margin: 0; }
.alg-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.alg-nav a:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
.alg-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
}
.alg-nav .alg-nav-icon {
  width: 16px;
  display: inline-flex;
  justify-content: center;
  opacity: 0.85;
  font-size: 14px;
}
.alg-nav-sub {
  list-style: none;
  padding: 2px 0 6px;
  margin: 0 0 0 0;
  background: rgba(0,0,0,0.18);
  border-left: 3px solid var(--border);
}
.alg-nav-sub a {
  padding: 6px 20px 6px 50px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-left: 0;
}
.alg-nav-sub a:hover { color: var(--text); background: transparent; }
.alg-nav-sub a.active { color: var(--accent); background: transparent; font-weight: 600; }

/* ----- Main ----- */
.alg-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.alg-topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border);
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.alg-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.alg-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.12s, background 0.12s;
}
.alg-search input::placeholder { color: var(--text-muted); }
.alg-search input:focus {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.alg-search::before {
  content: "⌕";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.alg-topbar-spacer { flex: 1; }

.alg-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}
.alg-user:hover { border-color: var(--border); background: var(--bg-elev-2); color: var(--text); }
.alg-user .alg-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #0d1b2a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}
.alg-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  min-width: 160px;
  display: none;
  z-index: 50;
}
.alg-user:hover .alg-user-menu,
.alg-user:focus-within .alg-user-menu { display: block; }
.alg-user-menu a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-dim);
  border-radius: 4px;
}
.alg-user-menu a:hover { background: var(--bg-elev-2); color: var(--text); }

.alg-content {
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
}

.alg-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.alg-page-header h1 { margin: 0; }
.alg-page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* ----- Cards ----- */
.alg-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.alg-card + .alg-card { margin-top: 16px; }
.alg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.alg-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.alg-card-sub { color: var(--text-muted); font-size: 12px; }

/* Stat tile */
.alg-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.alg-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.alg-stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.alg-stat-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.alg-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}
.alg-stat-sub { color: var(--text-dim); font-size: 12px; }
.alg-stat.accent-info::before { background: var(--info); }
.alg-stat.accent-warn::before { background: var(--warn); }
.alg-stat.accent-success::before { background: var(--success); }

/* ----- Buttons ----- */
.alg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none;
  line-height: 1.3;
}
.alg-btn:hover { background: var(--card-hover); border-color: #2d3e5c; color: var(--text); }
.alg-btn-primary {
  background: var(--accent);
  color: #0d1b2a;
  border-color: var(--accent);
  font-weight: 600;
}
.alg-btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: #0d1b2a; }
.alg-btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.alg-btn-danger:hover { background: rgba(239,92,92,0.1); color: var(--danger); }
.alg-btn-sm { padding: 5px 10px; font-size: 12px; }
.alg-btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.alg-btn-ghost:hover { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }

/* ----- Forms ----- */
.alg-field { margin-bottom: 14px; }
.alg-label {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.alg-input, .alg-select, .alg-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.12s, background 0.12s;
}
.alg-input:focus, .alg-select:focus, .alg-textarea:focus {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.alg-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238aa0b5'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  padding-right: 32px;
}
.alg-textarea { min-height: 80px; resize: vertical; }
.alg-checkbox, .alg-radio { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.alg-checkbox input, .alg-radio input { width: 16px; height: 16px; accent-color: var(--accent); }
.alg-field-inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

/* ----- Tables ----- */
.alg-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.alg-table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  flex-wrap: wrap;
}
.alg-table-toolbar .alg-input,
.alg-table-toolbar .alg-select { max-width: 220px; padding: 6px 10px; font-size: 13px; }
.alg-table-scroll { overflow-x: auto; }
.alg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.alg-table thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-elev-2);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.alg-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  vertical-align: middle;
}
.alg-table tbody tr:hover td { background: var(--bg-elev-2); color: var(--text); }
.alg-table tbody tr:last-child td { border-bottom: 0; }
.alg-table .alg-td-num { font-variant-numeric: tabular-nums; text-align: right; }
.alg-table .alg-td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.alg-table a { color: var(--accent); }
.alg-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-muted);
  font-size: 12px;
}

/* Badges */
.alg-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.alg-badge-ok     { background: rgba(46, 204, 113, 0.14); color: var(--success); border-color: rgba(46, 204, 113, 0.25); }
.alg-badge-warn   { background: rgba(240, 180, 41, 0.14); color: var(--warn);    border-color: rgba(240, 180, 41, 0.3); }
.alg-badge-danger { background: rgba(239, 92, 92, 0.14);  color: var(--danger);  border-color: rgba(239, 92, 92, 0.3); }
.alg-badge-info   { background: rgba(90, 168, 255, 0.14); color: var(--info);    border-color: rgba(90, 168, 255, 0.3); }

/* Alerts */
.alg-alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
}
.alg-alert-ok     { border-color: rgba(46, 204, 113, 0.4); background: rgba(46, 204, 113, 0.08); color: #96e3b3; }
.alg-alert-warn   { border-color: rgba(240, 180, 41, 0.4); background: rgba(240, 180, 41, 0.08); color: #f0cb6e; }
.alg-alert-danger { border-color: rgba(239, 92, 92, 0.4);  background: rgba(239, 92, 92, 0.08);  color: #ff8a8a; }

/* Chart container */
.alg-chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 22px;
}
.alg-year-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.alg-year-chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
}
.alg-year-chip:hover { border-color: #2d3e5c; color: var(--text); }
.alg-year-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1b2a;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 900px) {
  .alg-sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .alg-sidebar.open { transform: translateX(0); }
  .alg-main { margin-left: 0; }
  .alg-content { padding: 16px; }
  .alg-search { max-width: none; }
}

/* Login screen (index.php) override */
.alg-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #16283f, #0a1420 70%);
  padding: 20px;
}
.alg-login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.alg-login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.alg-login-brand .brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-soft); }
.alg-login-sub { color: var(--text-muted); text-align: center; font-size: 12.5px; margin: -14px 0 22px; }
.alg-login button { width: 100%; margin-top: 8px; justify-content: center; padding: 10px; font-size: 14px; }

/* Utilities */
.alg-flex       { display: flex; }
.alg-flex-col   { display: flex; flex-direction: column; }
.alg-gap-sm     { gap: 8px; }
.alg-gap        { gap: 12px; }
.alg-gap-lg     { gap: 18px; }
.alg-text-muted { color: var(--text-muted); }
.alg-text-dim   { color: var(--text-dim); }
.alg-text-right { text-align: right; }
.alg-mt-0       { margin-top: 0; }
.alg-mb-0       { margin-bottom: 0; }
.alg-mt         { margin-top: 16px; }
.alg-mb         { margin-bottom: 16px; }
.alg-small      { font-size: 12px; }

/* Hide legacy bootstrap 2 remnants that we're replacing */
.navbar-inverse,
.navbar-inner,
#sidebar-nav,
.content > .container-fluid > .row-fluid.stats-row,
.breadcrumbs { display: none !important; }

/* Keep bootstrap 2 chart area styling sane inside new .alg-chart-wrap */
.alg-chart-wrap .flot-chart-container,
.alg-chart-wrap #main-chart { width: 100%; height: 320px; }
