/* ==========================================================================
   OCTG CRM — Master Design System v3.0
   Single source of truth. One font. One rhythm. Zero AI patterns.
   Reference: Linear, Stripe, GitHub, Vercel Dashboard
   ========================================================================== */

/* Inter loaded via <link> in header.php — no @import needed here */


/* ==========================================================================
   1. RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   2. DESIGN TOKENS
   ========================================================================== */
:root {
  /* ── Font ── */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: var(--font);

  /* ── Typographic Scale (strict — never deviate) ── */
  /* Display Title  */  --text-display:   24px;  --lh-display:  1.15;  --fw-display:  700;  --ls-display:  -0.6px;
  /* Page Title     */  --text-page:      20px;  --lh-page:     1.2;   --fw-page:     650;  --ls-page:     -0.4px;
  /* Section Title  */  --text-section:   15px;  --lh-section:  1.3;   --fw-section:  600;  --ls-section:  -0.2px;
  /* Card Title     */  --text-card:      13px;  --lh-card:     1.4;   --fw-card:     600;  --ls-card:     -0.1px;
  /* Body           */  --text-body:      13.5px; --lh-body:    1.55;  --fw-body:     400;  --ls-body:     0px;
  /* Caption        */  --text-caption:   11.5px; --lh-caption: 1.4;   --fw-caption:  450;  --ls-caption:  0px;
  /* Table          */  --text-table:     13px;   --lh-table:   1.5;   --fw-table:    400;  --ls-table:    0px;
  /* Button         */  --text-btn:       13px;   --lh-btn:     1;     --fw-btn:      500;  --ls-btn:      0px;
  /* Input          */  --text-input:     13.5px; --lh-input:   1.5;   --fw-input:    400;  --ls-input:    0px;
  /* Label          */  --text-label:     11.5px; --lh-label:   1.4;   --fw-label:    500;  --ls-label:    0.1px;

  /* ── 8px Spacing Scale (strict — only these values) ── */
  --sp-1:  4px;   /* 0.5 unit  */
  --sp-2:  8px;   /* 1 unit    */
  --sp-3:  12px;  /* 1.5 units */
  --sp-4:  16px;  /* 2 units   */
  --sp-5:  20px;  /* 2.5 units */
  --sp-6:  24px;  /* 3 units   */
  --sp-8:  32px;  /* 4 units   */
  --sp-10: 40px;  /* 5 units   */
  --sp-12: 48px;  /* 6 units   */
  --sp-16: 64px;  /* 8 units   */

  /* ── Brand Colors ── */
  --accent:         #004741;
  --accent-dim:     rgba(0, 71, 65, 0.07);
  --accent-glow:    rgba(0, 71, 65, 0.14);
  --accent-hover:   #003430;
  --accent-text:    #FFFFFF;

  /* ── Surface (Light / Sand palette) ── */
  --bg-base:        #F0EDE4;
  --bg-surface:     #FAFAF8;
  --bg-elevated:    #F0EDE4;
  --bg-overlay:     #E8E4D9;
  --bg-hover:       #ECEAE0;

  /* ── Borders (refined — not invisible, not heavy) ── */
  --border-subtle:  rgba(0, 71, 65, 0.07);
  --border-default: rgba(0, 71, 65, 0.12);
  --border-strong:  rgba(0, 71, 65, 0.22);

  /* ── Text ── */
  --text-primary:   #1A2120;
  --text-secondary: #4B5856;
  --text-muted:     #8A9694;
  --text-inverse:   #FFFFFF;

  /* ── Semantic Colors ── */
  --green:      #16a34a;  --green-dim:  rgba(22, 163, 74, 0.1);
  --amber:      #d97706;  --amber-dim:  rgba(217, 119, 6, 0.1);
  --red:        #dc2626;  --red-dim:    rgba(220, 38, 38, 0.1);
  --cyan:       #0891b2;  --cyan-dim:   rgba(8, 145, 178, 0.1);
  --purple:     #7c3aed;  --purple-dim: rgba(124, 58, 237, 0.1);

  /* ── Layout ── */
  --sidebar-width:  232px;
  --topbar-height:  56px;

  /* ── Border Radius (one global system) ── */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Shadows (single-layer, subtle elevation only) ── */
  --shadow-xs:  0 1px 2px rgba(0, 71, 65, 0.04);
  --shadow-sm:  0 1px 4px rgba(0, 71, 65, 0.06);
  --shadow-md:  0 4px 12px rgba(0, 71, 65, 0.08);
  --shadow-lg:  0 8px 24px rgba(0, 71, 65, 0.10);
  --shadow-glow: 0 0 0 3px var(--accent-glow);

  /* ── Motion ── */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 100ms;
  --dur-base: 160ms;
  --dur-slow: 280ms;
}

/* ── Dark Mode ── */
html.theme-dark {
  --bg-base:        #0C1110;
  --bg-surface:     #131A19;
  --bg-elevated:    #1B2524;
  --bg-overlay:     #232F2E;
  --bg-hover:       #2A3736;

  --border-subtle:  rgba(240, 237, 228, 0.06);
  --border-default: rgba(240, 237, 228, 0.10);
  --border-strong:  rgba(240, 237, 228, 0.18);

  --accent:         #00635A;
  --accent-dim:     rgba(0, 99, 90, 0.14);
  --accent-glow:    rgba(0, 99, 90, 0.22);
  --accent-hover:   #004F47;

  --text-primary:   #EEF0EE;
  --text-secondary: #9EADAB;
  --text-muted:     #647270;
  --text-inverse:   #0C1110;

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm:  0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   3. BASE
   ========================================================================== */
html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a           { color: inherit; text-decoration: none; }
button      { font-family: var(--font); cursor: pointer; border: none; background: none; }
input,
select,
textarea    { font-family: var(--font); }
img         { display: block; max-width: 100%; }

/* ==========================================================================
   4. LAYOUT SHELL
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   5. SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--dur-slow) var(--ease);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.sidebar-search {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}

.sidebar-search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px var(--sp-3);
  transition: border-color var(--dur-base) var(--ease-std);
}

.sidebar-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sidebar-search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  width: 100%;
}

.sidebar-search-box input::placeholder { color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  padding: var(--sp-2) var(--sp-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
  margin-top: var(--sp-2);
}

.sidebar-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 450;
  transition: background var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std);
  position: relative;
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--dur-base);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  line-height: 1.6;
}

.nav-badge.green { background: var(--green-dim); color: var(--green); }

.sidebar-footer {
  padding: var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-std);
}

.sidebar-user:hover { background: var(--bg-hover); }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ==========================================================================
   6. TOPBAR
   ========================================================================== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}

.breadcrumb-root {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.breadcrumb-sep { color: var(--text-muted); }

.breadcrumb-current {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  width: 220px;
  transition: border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std);
  cursor: text;
}

.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: var(--font);
  width: 100%;
}

.topbar-search input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); flex-shrink: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-std),
              color var(--dur-base) var(--ease-std);
  position: relative;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn .notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--bg-surface);
}

.mobile-menu-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ==========================================================================
   7. PAGE LAYOUT
   ========================================================================== */
.page-content {
  padding: var(--sp-8) var(--sp-8);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.page-fade-in {
  animation: pageFadeIn var(--dur-slow) var(--ease) both;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.page-title-group {}

.page-title {
  font-family: var(--font);
  font-size: var(--text-page);
  font-weight: var(--fw-page);
  letter-spacing: var(--ls-page);
  color: var(--text-primary);
  line-height: var(--lh-page);
}

.page-subtitle {
  margin-top: var(--sp-1);
  font-size: var(--text-caption);
  color: var(--text-muted);
  font-weight: var(--fw-caption);
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* ==========================================================================
   8. BUTTONS (strict 4-variant system — no inventing new styles)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px var(--sp-4);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-btn);
  font-weight: var(--fw-btn);
  letter-spacing: var(--ls-btn);
  line-height: var(--lh-btn);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-std),
              border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std),
              color var(--dur-base) var(--ease-std);
  text-decoration: none;
  user-select: none;
}

/* Primary */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* Danger */
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(220, 38, 38, 0.2);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Sizes */
.btn-sm {
  padding: 5px var(--sp-3);
  font-size: 12px;
}

.btn-lg {
  padding: 10px var(--sp-6);
  font-size: 14px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
}

/* ==========================================================================
   9. FORMS
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.form-label {
  font-size: var(--text-label);
  font-weight: var(--fw-label);
  color: var(--text-secondary);
  letter-spacing: var(--ls-label);
  line-height: var(--lh-label);
}

.form-input,
.form-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-input);
  font-weight: var(--fw-input);
  line-height: var(--lh-input);
  outline: none;
  width: 100%;
  transition: border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std);
}

.form-input:hover,
.form-select:hover  { border-color: var(--border-strong); }

.form-input:focus,
.form-select:focus  {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select { cursor: pointer; }

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: calc(var(--sp-1) * -1);
}

.form-error {
  font-size: 11.5px;
  color: var(--red);
  line-height: 1.4;
}

/* Form row groups */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-section-title {
  font-size: var(--text-card);
  font-weight: var(--fw-card);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  letter-spacing: var(--ls-card);
}

/* ==========================================================================
   10. CARDS & PANELS
   ========================================================================== */

/* Base panel — clean, no shadow by default */
.panel,
.app-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.panel-title {
  font-family: var(--font);
  font-size: var(--text-card);
  font-weight: var(--fw-card);
  color: var(--text-primary);
  letter-spacing: var(--ls-card);
}

.panel-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.panel-body {
  padding: var(--sp-5);
}

.panel-body-flush {
  padding: 0;
}

/* Section card — slightly more prominent */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   11. KPI / STAT CARDS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}

.stat-card,
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-5) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std);
}

.stat-card:hover,
.kpi-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.stat-card-header,
.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label,
.kpi-label {
  font-size: var(--text-label);
  font-weight: var(--fw-label);
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.stat-icon,
.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-value,
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-change,
.kpi-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-caption);
}

.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-change.neutral { color: var(--text-muted); }

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
}

.kpi-trend.up   { background: var(--green-dim); color: var(--green); }
.kpi-trend.down { background: var(--red-dim);   color: var(--red); }
.kpi-trend.flat { background: var(--bg-elevated); color: var(--text-muted); }

/* Icon color variants */
.stat-icon.blue, .kpi-icon.blue  { background: var(--accent-dim); color: var(--accent); }
.stat-icon.green, .kpi-icon.green { background: var(--green-dim); color: var(--green); }
.stat-icon.amber, .kpi-icon.amber { background: var(--amber-dim); color: var(--amber); }
.stat-icon.red, .kpi-icon.red    { background: var(--red-dim);   color: var(--red); }
.stat-icon.cyan, .kpi-icon.cyan  { background: var(--cyan-dim);  color: var(--cyan); }
.stat-icon.purple               { background: var(--purple-dim); color: var(--purple); }

/* ==========================================================================
   12. DATA TABLES
   ========================================================================== */
.data-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* Sticky headers */
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table thead th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast) var(--ease-std);
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table td {
  padding: 11px var(--sp-4);
  font-size: var(--text-table);
  color: var(--text-secondary);
  vertical-align: middle;
  line-height: 1.4;
}

/* Primary column emphasis */
.data-table td:first-child,
.data-table td.td-primary {
  color: var(--text-primary);
  font-weight: 500;
}

/* Table action buttons */
.table-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  justify-content: flex-end;
}

/* ==========================================================================
   13. BADGES
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-blue   { background: var(--accent-dim); color: var(--accent); }
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-muted  { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* ==========================================================================
   14. MODULE GRID CARDS
   ========================================================================== */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.module-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std);
  text-decoration: none;
  color: inherit;
}

.module-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.module-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.module-icon.blue   { background: var(--accent-dim); color: var(--accent); }
.module-icon.green  { background: var(--green-dim);  color: var(--green); }
.module-icon.amber  { background: var(--amber-dim);  color: var(--amber); }
.module-icon.cyan   { background: var(--cyan-dim);   color: var(--cyan); }
.module-icon.red    { background: var(--red-dim);    color: var(--red); }
.module-icon.purple { background: var(--purple-dim); color: var(--purple); }

.module-card-title {
  font-size: var(--text-card);
  font-weight: var(--fw-card);
  color: var(--text-primary);
  letter-spacing: var(--ls-card);
  margin-bottom: 3px;
}

.module-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.module-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

.module-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.module-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.module-status-dot.active  { background: var(--green); }
.module-status-dot.standby { background: var(--amber); }
.module-status-dot.off     { background: var(--text-muted); }

.module-arrow {
  color: var(--text-muted);
  transition: transform var(--dur-base) var(--ease-std),
              color var(--dur-base) var(--ease-std);
}

.module-card:hover .module-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

/* ==========================================================================
   15. CONTENT GRIDS
   ========================================================================== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.content-grid.thirds  { grid-template-columns: 2fr 1fr; }
.content-grid.quarter { grid-template-columns: 3fr 1fr; }

/* ==========================================================================
   16. PROGRESS BAR
   ========================================================================== */
.progress-bar {
  height: 3px;
  background: var(--bg-overlay);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}

.progress-fill.green  { background: var(--green); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.red    { background: var(--red); }

/* ==========================================================================
   17. ACTIVITY FEED
   ========================================================================== */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast);
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-hover); }

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.activity-content { flex: 1; min-width: 0; }

.activity-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong { color: var(--text-primary); font-weight: 500; }

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   18. METRIC ROW
   ========================================================================== */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.metric-row:last-child { border-bottom: none; }

.metric-row-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.metric-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   19. EMPTY STATE
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
}

.empty-icon {
  font-size: 28px;
  opacity: 0.25;
}

.empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.5;
}

/* ==========================================================================
   20. SKELETON LOADER
   ========================================================================== */
@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   21. DIVIDER & TAGS
   ========================================================================== */
.divider { height: 1px; background: var(--border-subtle); }

.tag-list { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

.tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* ==========================================================================
   22. TOOLTIP
   ========================================================================== */
[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  border-radius: var(--radius-xs);
  padding: 3px 7px;
  font-size: 11px;
  color: var(--bg-surface);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast);
  z-index: 200;
}

[data-tip]:hover::after { opacity: 1; }

/* ==========================================================================
   23. SCROLLBAR
   ========================================================================== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ==========================================================================
   24. STAGGER ANIMATION
   ========================================================================== */
.stagger > * { animation: pageFadeIn var(--dur-slow) var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay:   0ms; }
.stagger > *:nth-child(2) { animation-delay:  40ms; }
.stagger > *:nth-child(3) { animation-delay:  80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }

/* ==========================================================================
   25. LOGIN PAGE
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.login-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10);
  width: 100%;
  max-width: 376px;
  box-shadow: var(--shadow-md);
  animation: pageFadeIn 0.4s var(--ease) both;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
}

.login-title {
  font-size: var(--text-page);
  font-weight: var(--fw-page);
  letter-spacing: var(--ls-page);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.login-subtitle {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
}

.login-footer-text {
  text-align: center;
  margin-top: var(--sp-6);
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer-text a { color: var(--accent); }

/* ==========================================================================
   26. AI COPILOT / ADVISOR
   ========================================================================== */
.advisor-prompt {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  transition: border-color var(--dur-base) var(--ease-std),
              box-shadow var(--dur-base) var(--ease-std);
}

.advisor-prompt:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.advisor-prompt input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13.5px;
  flex: 1;
}

.advisor-prompt input::placeholder { color: var(--text-muted); }

.advisor-send-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background var(--dur-base);
}

.advisor-send-btn:hover { background: var(--accent-hover); }

/* ==========================================================================
   27. STATUS PILL (topbar punch clock)
   ========================================================================== */
.status-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--green-dim);
  border: 1px solid rgba(22, 163, 74, 0.15);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-size: 11.5px;
  color: var(--green);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-std);
}

.status-pill:hover { background: rgba(22, 163, 74, 0.14); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulseDot 2.5s ease infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}

/* ==========================================================================
   28. SIDEBAR OVERLAY
   ========================================================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.show,
.sidebar-overlay.open { display: block; }

/* ==========================================================================
   29. RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
  .content-grid,
  .content-grid.thirds,
  .content-grid.quarter {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  .topbar { padding: 0 var(--sp-4); }

  .topbar-search { display: none; }

  .page-content { padding: var(--sp-5) var(--sp-4); gap: var(--sp-5); }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .module-grid { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; gap: var(--sp-3); }

  .mobile-menu-btn { display: flex; }

  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .page-header-actions { flex-direction: column; width: 100%; }
  .page-header-actions .btn { width: 100%; }
  .data-table th, .data-table td { padding: var(--sp-2) var(--sp-3); font-size: 12px; }
}

/* ==========================================================================
   30. ENTERPRISE UI/UX POLISH & ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Universal Focus visible for Keyboard Accessibility (WCAG AA) */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
}

/* Accessible touch targets on mobile/tablet screens */
@media (max-width: 768px) {
  .btn,
  .form-input,
  .form-select,
  .sidebar-nav-item,
  .user-dropdown-item {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* Cohesive component state transitions (180ms ease) */
.btn,
.form-input,
.form-select,
.panel,
.app-card,
.sidebar-nav-item,
.user-dropdown-item {
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Standardized Disabled states */
.btn:disabled,
.btn[disabled],
.btn.disabled {
  opacity: 0.45 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
}

.form-input:disabled,
.form-select:disabled,
.form-input[disabled],
.form-select[disabled] {
  background: var(--bg-hover) !important;
  color: var(--text-muted) !important;
  border-color: var(--border-subtle) !important;
  cursor: not-allowed !important;
}

/* Empty State Polish */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.01);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: var(--sp-3);
  opacity: 0.8;
}

.empty-title {
  font-size: var(--text-card);
  font-weight: var(--fw-card);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.empty-desc {
  font-size: var(--text-caption);
  color: var(--text-muted);
  max-width: 280px;
}

/* Premium Skeleton Loaders */
@keyframes skeleton-loading {
  0% { background-color: rgba(0, 71, 65, 0.05); }
  50% { background-color: rgba(0, 71, 65, 0.12); }
  100% { background-color: rgba(0, 71, 65, 0.05); }
}

.skeleton {
  animation: skeleton-loading 1.5s ease-in-out infinite;
  background-color: rgba(0, 71, 65, 0.05);
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 12px;
  width: 100%;
  margin-bottom: 8px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}


/* Sticky Actions Column */
.data-table th.sticky-actions, .data-table td.sticky-actions { position: sticky; right: 0; background: var(--bg-elevated); z-index: 1; white-space: nowrap; box-shadow: -2px 0 5px rgba(0,0,0,0.1); }
.data-table td.sticky-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; align-items: center; height: 100%; }
