/* =====================================================================
   APJ Accounts Management System — Design System
   Palette grounded in precision-instrument / machine-shop language:
   gunmetal sidebar, oxide-blue primary, calibration-amber accent.
   ===================================================================== */

:root {
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --surface-alt: #F6F8FA;
  --sidebar-bg: #101820;
  --sidebar-bg-active: #1B2733;
  --sidebar-text: #AEB9C4;
  --sidebar-text-active: #FFFFFF;
  --primary: #2B6E8F;
  --primary-dark: #204F68;
  --accent: #E2A33B;
  --accent-2: #4FB0A5;
  --text: #172029;
  --text-muted: #64748B;
  --border: #DFE4E9;
  --success: #2E9E63;
  --danger: #D6483F;
  --warning: #E2A33B;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.04), 0 4px 12px rgba(16, 24, 32, 0.06);
  --font-display: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: #0B1119;
  --surface: #131B24;
  --surface-alt: #0F161D;
  --sidebar-bg: #0A0F15;
  --sidebar-bg-active: #172230;
  --text: #E4E9EE;
  --text-muted: #8A97A3;
  --border: #232E3A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: width 0.18s ease;
  border-right: 1px solid rgba(255,255,255,0.06);
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #fff;
  font-family: var(--font-display);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .mark {
  width: 32px; height: 32px; border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 600; font-size: 15px; }
.sidebar-brand .sub { display: block; font-size: 11px; color: var(--sidebar-text); font-weight: 400; }
body.sidebar-collapsed .sidebar-brand .name-block { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #5C6773; padding: 14px 12px 6px; font-weight: 600;
}
body.sidebar-collapsed .sidebar-section-label { display: none; }

.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  margin-bottom: 2px;
}
.sidebar-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }
.sidebar-link:hover { background: var(--sidebar-bg-active); color: #fff; }
.sidebar-link.active { background: var(--sidebar-bg-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
body.sidebar-collapsed .sidebar-link span { display: none; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-toggle-btn {
  width: 100%; background: none; border: 1px solid rgba(255,255,255,0.12);
  color: var(--sidebar-text); border-radius: var(--radius); padding: 8px; cursor: pointer;
}
.sidebar-toggle-btn:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  transition: margin-left 0.18s ease;
}
body.sidebar-collapsed .main-area { margin-left: var(--sidebar-w-collapsed); }

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-toggle { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; }
.search-box {
  flex: 1; max-width: 420px; position: relative;
}
.search-box input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); font-size: 13px;
}
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid transparent; background: none; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}
.profile-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; }
.profile-chip:hover { background: var(--surface-alt); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; font-family: var(--font-display);
}
.profile-chip .role { font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Content
   --------------------------------------------------------------------- */
.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-muted); }
.page-title { font-size: 21px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-alt); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-card .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-card .kpi-icon {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-card .kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; margin-top: 2px; }
.kpi-card .kpi-delta { font-size: 11.5px; margin-top: 6px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

.tint-primary { background: rgba(43,110,143,0.12); color: var(--primary); }
.tint-accent  { background: rgba(226,163,59,0.16); color: #A66A16; }
.tint-success { background: rgba(46,158,99,0.14); color: var(--success); }
.tint-danger  { background: rgba(214,72,63,0.13); color: var(--danger); }

/* Panels / charts */
.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 950px) { .panel-grid { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
}
.panel-title { font-size: 14px; margin-bottom: 4px; }
.panel-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

/* Precision-gauge signature element (used on login + as an inventory/OEE ring) */
.gauge { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.gauge svg { transform: rotate(-90deg); }
.gauge-value {
  position: absolute; font-family: var(--font-mono); font-weight: 600; font-size: 15px; color: var(--text);
}

/* Tables */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600;
}
table.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
table.data-table tr:hover td { background: var(--surface-alt); }

.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Login screen
   --------------------------------------------------------------------- */
.login-shell { min-height: 100vh; display: flex; }
.login-side {
  flex: 1.1; background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; justify-content: center; padding: 60px;
  position: relative; overflow: hidden;
}
.login-side .eyebrow { color: var(--accent); font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 14px; }
.login-side h1 { font-size: 32px; color: #fff; max-width: 420px; line-height: 1.25; }
.login-side p { color: #9AA7B4; max-width: 380px; margin-top: 14px; font-size: 14px; }
.login-side .gauge-deco { position: absolute; right: -60px; bottom: -60px; opacity: 0.5; }

.login-form-side {
  flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 40px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.login-card .lead { color: var(--text-muted); font-size: 13.5px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: var(--font-body);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,110,143,0.15);
}
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-danger { background: rgba(214,72,63,0.1); color: var(--danger); border: 1px solid rgba(214,72,63,0.25); }
.alert-success { background: rgba(46,158,99,0.1); color: var(--success); border: 1px solid rgba(46,158,99,0.25); }

@media (max-width: 860px) {
  .login-side { display: none; }
}
