/* ==========================================================================
   Triad Dashboard — style.css
   Core 2.0 Dashboard Builder aesthetic
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Font Face Declarations — Inter Display (woff2)
   -------------------------------------------------------------------------- */

@font-face {
  font-family: 'Inter Display';
  src: url('../fonts/InterDisplay-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('../fonts/InterDisplay-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('../fonts/InterDisplay-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('../fonts/InterDisplay-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('../fonts/InterDisplay-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. CSS Reset
   -------------------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  font-family: 'Inter Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  background: var(--bg-surface1);
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* --------------------------------------------------------------------------
   3. CSS Custom Properties — Dark Theme (Core 2.0 template)
   -------------------------------------------------------------------------- */

:root {
  /* Shades (from template) */
  --shade-01: #141414;
  --shade-02: #101010;
  --shade-03: #191919;
  --shade-04: #222222;
  --shade-05: #4c4c4c;
  --shade-06: #727272;
  --shade-07: #7b7b7b;
  --shade-08: #e2e2e2;
  --shade-09: #f1f1f1;
  --shade-10: #fdfdfd;

  /* Primary colors */
  --color-blue: #2a85ff;
  --color-green: #00a656;
  --color-red: #ff381c;
  --color-purple: #7f5fff;
  --color-orange: #ff9d34;
  --color-yellow: #ffc233;

  /* Semantic — surfaces */
  --bg-surface1: #101010;
  --bg-surface2: #191919;
  --bg-surface2-overlay: #101010;
  --bg-pop: #222222;
  --bg-highlight: #222222;
  --bg-depth: #1d1d1d;

  /* Semantic — text */
  --text-primary: #f1f1f1;
  --text-secondary: #7b7b7b;
  --text-tertiary: #727272;
  --text-light: #141414;

  /* Semantic — strokes */
  --stroke-border: #272727;
  --stroke-subtle: #1e1e1e;
  --stroke-stroke2: #282828;
  --stroke-highlight: rgba(114, 114, 114, 0.5);
  --stroke-focus: #2a85ff;

  /* Shadows (dark mode values from template) */
  --shadow-depth:
    0px 2.15px 0.5px -2px rgba(0, 0, 0, 0.25),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.2),
    0px 6px 4px -4px rgba(8, 8, 8, 0.16),
    0px 6px 13px 0px rgba(8, 8, 8, 0.12),
    0px 24px 24px -16px rgba(8, 8, 8, 0.08),
    inset 2px 4px 16px 0px rgba(253, 253, 253, 0.05);
  --shadow-widget:
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  --shadow-dropdown:
    0px 16px 48px -4px rgba(0, 0, 0, 0.75),
    0px 0px 10px 0px rgba(0, 0, 0, 0.5),
    0px 2.15px 0.5px -2px rgba(0, 0, 0, 0.25),
    0px 24px 24px -16px rgba(8, 8, 8, 0.04),
    0px 6px 13px 0px rgba(8, 8, 8, 0.03),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.09);
  --shadow-elevated:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  --shadow-input-typing:
    0px 4px 4px 0px rgba(18, 18, 18, 0.81) inset,
    0px 0px 0px 3px rgba(40, 40, 40, 0.1) inset;

  /* Layout constants */
  --sidebar-width: 280px;
  --header-height: 88px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-3xl: 24px;
  --radius-4xl: 32px;
  --radius-full: 9999px;

  /* Transition */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* --------------------------------------------------------------------------
   4. Typography Classes
   -------------------------------------------------------------------------- */

.text-h1 {
  font-size: 6rem;
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.text-h2 {
  font-size: 3.75rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.text-h3 {
  font-size: 3rem;
  font-weight: 500;
  line-height: 1.25;
}

.text-h4 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.003em;
}

.text-h5 {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.text-h6 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.text-body-1 {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.015em;
}

.text-body-2 {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.025em;
}

.text-button {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
}

.text-caption {
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: -0.02em;
}

.text-overline {
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   5. Layout Classes
   -------------------------------------------------------------------------- */

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface1);
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-slow);
  scrollbar-width: thin;
  scrollbar-color: rgba(123, 123, 123, 0.5) var(--bg-surface2);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(34, 34, 34, 0.9);
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
}

.sidebar-logo span {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-section-label {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  flex-shrink: 0;
}

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

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 32px;
  background: var(--bg-surface1);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}

.header-toggle:hover {
  background: var(--stroke-subtle);
}

.header-search {
  position: relative;
}

.header-search input {
  width: 280px;
  height: 48px;
  padding: 0 16px 0 42px;
  border-radius: var(--radius-3xl);
  border: 1px solid transparent;
  background: var(--bg-surface2);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  outline: none;
}

.header-search input::placeholder {
  color: var(--text-tertiary);
}

.header-search input:focus {
  border-color: var(--stroke-stroke2);
  box-shadow: var(--shadow-input-typing);
  background: transparent;
}

.header-search svg {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Content area */
.content {
  flex: 1;
  padding: 32px 20px;
}

/* Centered container */
.center {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   6. Card Component
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-surface2);
  border-radius: var(--radius-4xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   7. Button Components
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-3xl);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
  user-select: none;
  text-decoration: none;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Primary — Core 2.0 "isBlack" dark variant (light on dark) */
.btn-primary {
  background: linear-gradient(180deg, var(--shade-10) 0%, #dedede 100%);
  color: var(--shade-01);
  box-shadow: inset 2px 0px 8px 2px rgba(248, 248, 248, 0.20);
  position: relative;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e8e8e8 100%);
  box-shadow: inset 2px 0px 8px 2px rgba(24, 24, 24, 0.25);
}

/* Secondary — Core 2.0 "isWhite" dark variant */
.btn-secondary {
  background: linear-gradient(180deg, #2a2a2a 0%, #202020 100%);
  color: var(--text-secondary);
  border: none;
}

.btn-secondary:hover {
  color: var(--text-primary);
  box-shadow: var(--shadow-depth);
}

/* Danger */
.btn-danger {
  background: var(--color-red);
  color: #ffffff;
}

.btn-danger:hover {
  background: #e02e15;
  box-shadow: 0 4px 12px rgba(255, 56, 28, 0.2);
}

/* Ghost — Core 2.0 "isGray" dark variant */
.btn-ghost {
  background: var(--shade-04);
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  box-shadow: var(--shadow-depth);
}

/* Blue */
.btn-blue {
  background: var(--color-blue);
  color: #ffffff;
}

.btn-blue:hover {
  background: #1a75ef;
  box-shadow: 0 4px 12px rgba(42, 133, 255, 0.25);
}

/* Circle */
.btn-circle {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
}

/* Small */
.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 0.75rem;
  gap: 6px;
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

.btn-sm.btn-circle {
  width: 36px;
  height: 36px;
}

/* Icon-only */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.btn.btn-icon {
  width: 48px;
  padding: 0;
}

.btn-sm.btn-icon {
  width: 36px;
  padding: 0;
}

/* --------------------------------------------------------------------------
   8. Form Components
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  padding-left: 4px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-left: 4px;
}

.field-input {
  width: 100%;
  height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--stroke-stroke2);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: -0.025em;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
              background var(--transition-fast);
}

.field-input::placeholder {
  color: rgba(123, 123, 123, 0.5);
}

.field-input:hover {
  border-color: var(--stroke-highlight);
}

.field-input:focus {
  border-color: var(--stroke-highlight);
  box-shadow: var(--shadow-input-typing);
}

.field-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Textarea */
.field-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 18px;
  border-radius: var(--radius-3xl);
  border: 1px solid var(--stroke-stroke2);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: -0.025em;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
              background var(--transition-fast);
}

.field-textarea::placeholder {
  color: rgba(123, 123, 123, 0.5);
}

.field-textarea:hover {
  border-color: var(--stroke-highlight);
}

.field-textarea:focus {
  border-color: var(--stroke-highlight);
  box-shadow: var(--shadow-input-typing);
}

/* Select */
.field-select {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 18px;
  border-radius: var(--radius-3xl);
  border: 1px solid var(--stroke-stroke2);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: -0.025em;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field-select:hover {
  border-color: var(--stroke-highlight);
}

.field-select:focus {
  border-color: var(--stroke-highlight);
  box-shadow: var(--shadow-input-typing);
}

/* Error state */
.field-input.is-error,
.field-textarea.is-error,
.field-select.is-error {
  border-color: var(--color-red);
}

.field-input.is-error:focus,
.field-textarea.is-error:focus,
.field-select.is-error:focus {
  box-shadow: 0px 4px 4px 0px rgba(255, 56, 28, 0.2) inset;
}

.field-error {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-red);
  padding-left: 4px;
}

/* Checkbox / Toggle */
.field-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.field-toggle input {
  display: none;
}

.field-toggle-track {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-surface1);
  box-shadow: 0 0 0 1.5px inset var(--stroke-stroke2);
  position: relative;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.field-toggle input:checked + .field-toggle-track {
  background: #282828;
  box-shadow: none;
}

.field-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fcfcfc;
  box-shadow:
    inset 0px 2px 2px 0px #fff,
    0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-fast);
}

.field-toggle input:checked + .field-toggle-track::after {
  transform: translateX(20px);
}

/* --------------------------------------------------------------------------
   9. Table Component
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: rgba(114, 114, 114, 0.8);
  text-align: left;
  padding: 16px 20px;
  border-bottom: 1px solid var(--stroke-subtle);
}

.data-table td {
  font-size: 0.875rem;
  color: var(--text-primary);
  padding: 16px 20px;
  border-top: 1px solid var(--stroke-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--stroke-subtle);
}

.data-table tbody tr:first-child td {
  border-top: none;
}

/* Alignment helpers for table cells */
.data-table .cell-right {
  text-align: right;
}

.data-table .cell-center {
  text-align: center;
}

.data-table .cell-mono {
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   10. Badge / Label Components
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-green {
  background: rgba(0, 166, 86, 0.05);
  color: #00a656;
  border: 1px solid rgba(0, 166, 86, 0.15);
}

.badge-red {
  background: rgba(255, 106, 85, 0.05);
  color: #ff6a55;
  border: 1px solid rgba(255, 106, 85, 0.15);
}

.badge-yellow {
  background: rgba(239, 157, 14, 0.05);
  color: #ef9d0e;
  border: 1px solid rgba(239, 157, 14, 0.15);
}

.badge-blue {
  background: rgba(42, 133, 255, 0.05);
  color: var(--color-blue);
  border: 1px solid rgba(42, 133, 255, 0.15);
}

.badge-purple {
  background: rgba(127, 95, 255, 0.05);
  color: var(--color-purple);
  border: 1px solid rgba(127, 95, 255, 0.15);
}

.badge-gray {
  background: var(--bg-surface1);
  color: var(--text-secondary);
  border: 1px solid var(--stroke-stroke2);
}

.badge-orange {
  background: rgba(255, 157, 52, 0.05);
  color: var(--color-orange);
  border: 1px solid rgba(255, 157, 52, 0.15);
}

/* Dot badges (small status dot before text) */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

.badge-green.badge-dot::before { background: var(--color-green); }
.badge-red.badge-dot::before { background: var(--color-red); }
.badge-yellow.badge-dot::before { background: var(--color-yellow); }
.badge-blue.badge-dot::before { background: var(--color-blue); }
.badge-purple.badge-dot::before { background: var(--color-purple); }

/* --------------------------------------------------------------------------
   11. Modal Component
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 34, 34, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
  padding: 24px;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  background: var(--bg-surface2);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-dropdown);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--transition-base);
}

.modal-backdrop.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--stroke-border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-highlight);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--stroke-border);
  flex-shrink: 0;
}

/* Large modal variant */
.modal-lg {
  max-width: 720px;
}

/* --------------------------------------------------------------------------
   12. Navigation Components
   -------------------------------------------------------------------------- */

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 12px;
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  cursor: pointer;
  transition: color var(--transition-fast);
  text-decoration: none;
  user-select: none;
  position: relative;
}

.nav-item svg,
.nav-item img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

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

.nav-item:hover svg,
.nav-item:hover img {
  opacity: 1;
}

.nav-item.active {
  background: var(--bg-pop);
  color: var(--text-primary);
  box-shadow:
    0px 6px 4px -4px rgba(8, 8, 8, 0.05),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.09);
}

.nav-item.active svg,
.nav-item.active img {
  opacity: 1;
}

/* Nav badge (right side count) */
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-blue);
  color: #ffffff;
}

/* Dropdown nav */
.nav-dropdown {
  margin-bottom: 4px;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.nav-dropdown-toggle:hover {
  color: var(--text-primary);
}

.nav-dropdown-toggle svg.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-dropdown-toggle .chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}

.nav-dropdown.open .nav-dropdown-toggle .chevron {
  transform: rotate(180deg);
}

.nav-dropdown-items {
  display: none;
  padding-left: 36px;
  position: relative;
}

.nav-dropdown-items::before {
  content: '';
  position: absolute;
  top: 0;
  left: 23px;
  bottom: 48px;
  width: 1.5px;
  background: var(--stroke-stroke2);
}

.nav-dropdown.open .nav-dropdown-items {
  display: block;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  cursor: pointer;
  transition: color var(--transition-fast);
  text-decoration: none;
}

.nav-sub-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -13px;
  bottom: calc(50% - 0.75px);
  width: 13px;
  border-left: 1px solid var(--stroke-stroke2);
  border-bottom: 1px solid var(--stroke-stroke2);
  border-bottom-left-radius: 10px;
}

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

.nav-sub-item.active {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   13. Utility Classes
   -------------------------------------------------------------------------- */

/* Flexbox */
.flex         { display: flex; }
.inline-flex  { display: inline-flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; }
.items-start  { align-items: flex-start; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.self-start   { align-self: flex-start; }
.self-center  { align-self: center; }
.self-end     { align-self: flex-end; }

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

/* Margin top */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

/* Margin bottom */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }

/* Margin left / right */
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }
.px-2 { padding-left: 8px;  padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.py-2 { padding-top: 8px;  padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-5 { padding-top: 20px; padding-bottom: 20px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }

/* Width / Height */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-0 { min-height: 0; }

/* Border radius */
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-2xl  { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Text */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-blue      { color: var(--color-blue); }
.text-green     { color: var(--color-green); }
.text-red       { color: var(--color-red); }
.font-medium    { font-weight: 500; }
.font-semibold  { font-weight: 600; }
.font-bold      { font-weight: 700; }

/* Truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Display */
.hidden  { display: none; }
.block   { display: block; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* Grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Overflow */
.overflow-auto   { overflow: auto; }
.overflow-hidden { overflow: hidden; }

/* Borders */
.border-b { border-bottom: 1px solid var(--stroke-border); }
.border-t { border-top: 1px solid var(--stroke-border); }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }

/* Relative / Absolute */
.relative { position: relative; }
.absolute { position: absolute; }
.sticky   { position: sticky; }

/* Shrink */
.shrink-0 { flex-shrink: 0; }

/* --------------------------------------------------------------------------
   14. Page-Specific Components
   -------------------------------------------------------------------------- */

/* Page title */
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title h1 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.003em;
}

.page-title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Metric card */
.metric-card {
  background: var(--bg-surface2);
  border-radius: var(--radius-4xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-card-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  letter-spacing: 0.003em;
}

.metric-card-label {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: -0.025em;
}

.metric-card-change {
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.metric-card-change.up {
  color: var(--color-green);
}

.metric-card-change.down {
  color: var(--color-red);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  gap: 16px;
}

.empty-state svg,
.empty-state img {
  width: 64px;
  height: 64px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: -0.025em;
  max-width: 360px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 20px;
  border-radius: var(--radius-3xl);
  background: var(--shade-01);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-dropdown);
  transform: translateY(120%);
  opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
  pointer-events: none;
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-success {
  background: var(--color-green);
}

.toast-error {
  background: var(--color-red);
}

.toast-close {
  margin-left: auto;
  width: 20px;
  height: 20px;
  opacity: 0.7;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--stroke-border);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loading overlay */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--stroke-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

/* Divider */
.divider {
  width: 100%;
  height: 1px;
  background: var(--stroke-border);
  margin: 16px 0;
}

/* Tag / Chip */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--stroke-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.tag-close {
  width: 14px;
  height: 14px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.tag-close:hover {
  opacity: 1;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-primary);
  border-color: var(--stroke-stroke2);
}

/* Dropdown menu */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  min-width: 200px;
  background: var(--bg-surface2);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-4xl);
  box-shadow: var(--shadow-dropdown);
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), visibility var(--transition-fast),
              transform var(--transition-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

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

.dropdown-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.dropdown-item.danger {
  color: var(--color-red);
}

.dropdown-item.danger svg {
  color: var(--color-red);
}

.dropdown-divider {
  height: 1px;
  background: var(--stroke-subtle);
  margin: 12px -12px;
}

/* --------------------------------------------------------------------------
   15. Scrollbar Styling
   -------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(114, 114, 114, 0.5);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(114, 114, 114, 0.7);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(114, 114, 114, 0.5) transparent;
}

/* --------------------------------------------------------------------------
   17. Responsive
   -------------------------------------------------------------------------- */

/* Tablet and below */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay {
    display: block;
  }

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

  .header-toggle {
    display: flex;
  }

  .header {
    padding: 0 20px;
  }

  .content {
    padding: 24px 20px;
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-search input {
    width: 200px;
  }

  .header-title {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .content {
    padding: 20px 16px;
  }

  .header {
    padding: 0 16px;
  }

  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .page-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title-actions {
    width: 100%;
  }

  .page-title-actions .btn {
    flex: 1;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius-3xl);
  }

  .metric-card {
    padding: 16px;
    border-radius: var(--radius-3xl);
  }

  .metric-card-value {
    font-size: 1.5rem;
  }

  .modal {
    max-width: 100%;
    margin: 16px;
    border-radius: var(--radius-xl);
  }

  .page-title h1 {
    font-size: 1.5rem;
  }

  .header-title {
    font-size: 1.25rem;
  }

  .header-search {
    display: none;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    min-width: auto;
    max-width: none;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .text-h1 { font-size: 2rem; }
  .text-h2 { font-size: 1.5rem; }
  .text-h3 { font-size: 1.25rem; }
  .text-h4 { font-size: 1.25rem; }

  /* Responsive visibility helpers */
  .hide-mobile { display: none; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none; }
}

/* --------------------------------------------------------------------------
   18. Transitions & Animations
   -------------------------------------------------------------------------- */

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease forwards;
}

/* Slide up */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-slide-up {
  animation: slideUp var(--transition-slow) ease forwards;
}

/* Pulse (subtle live indicator) */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Skeleton loading */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--stroke-subtle) 25%,
    var(--stroke-border) 50%,
    var(--stroke-subtle) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-circle {
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   Selection & Focus
   -------------------------------------------------------------------------- */

::selection {
  background: rgba(42, 133, 255, 0.2);
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--stroke-highlight);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   19. Bridge — classes used by ui.js / pages.js
   -------------------------------------------------------------------------- */

/* ── Login Page ───────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-surface1);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface2);
  border-radius: var(--radius-4xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  padding: 48px 32px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo,
.brand-logo-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--color-blue);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  border-radius: var(--radius-md);
}

.brand-logo-lg {
  width: 64px;
  height: 64px;
  font-size: 1.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-top: 16px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: -0.025em;
  margin-top: 8px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
}

/* ── Sidebar brand / nav / user (ui.js layout) ───────────────── */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-label {
  /* text next to nav icons */
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: capitalize;
}

/* ── Header title / hamburger ─────────────────────────────────── */

.header-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.003em;
}

.hamburger {
  display: none;
}

@media (max-width: 1024px) {
  .hamburger {
    display: inline-flex;
  }
}

/* ── User dropdown (header) ───────────────────────────────────── */

.user-dropdown {
  position: relative;
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition-fast);
  overflow: hidden;
}

.user-dropdown-trigger:hover {
  background: var(--color-blue);
}

.user-dropdown-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--bg-surface2);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-4xl);
  box-shadow: var(--shadow-dropdown);
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
  z-index: 200;
}

.user-dropdown .dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item-danger {
  color: var(--color-red) !important;
}

/* ── Sidebar overlay .visible alias ───────────────────────────── */

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ── Alert ─────────────────────────────────────────────────────── */

.alert {
  padding: 16px 20px;
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  line-height: 1.5;
  letter-spacing: -0.025em;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--color-green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ── Metrics Grid ──────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metrics-grid-sm {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid-sm { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .metrics-grid,
  .metrics-grid-sm { grid-template-columns: 1fr; }
}

/* Aliases: ui.js metric() uses .metric-value / .metric-label / .metric-sub */
.metric-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  letter-spacing: 0.003em;
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: -0.025em;
  margin-top: 4px;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  letter-spacing: -0.02em;
  margin-top: 4px;
}

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

.metric-detail + .metric-detail::before {
  content: '·';
  margin: 0 6px;
  color: var(--text-tertiary);
}

/* ── Page Toolbar ──────────────────────────────────────────────── */

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Form Layout ───────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

/* ── Field aliases: ui.js uses .field-group + .input ──────────── */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group .field-label {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.field-group .input {
  height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--stroke-stroke2);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  letter-spacing: -0.025em;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field-group .input:focus {
  border-color: var(--stroke-highlight);
  box-shadow: var(--shadow-input-typing);
}

.field-group .input::placeholder {
  color: rgba(123, 123, 123, 0.5);
}

.field-group textarea.input {
  height: auto;
  min-height: 96px;
  padding: 14px 18px;
  border-radius: var(--radius-3xl);
  resize: vertical;
}

.field-group select.input {
  cursor: pointer;
  appearance: none;
  border-radius: var(--radius-3xl);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.field-group.has-error .input {
  border-color: var(--color-red);
}

.field-error {
  font-size: 12px;
  color: var(--color-red);
}

/* ── Table aliases: ui.js uses .table / .table-wrap ───────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 16px 20px;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: rgba(114, 114, 114, 0.8);
  border-bottom: 1px solid var(--stroke-subtle);
  white-space: nowrap;
}

.table td {
  padding: 16px 20px;
  color: var(--text-primary);
  border-top: 1px solid var(--stroke-subtle);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--stroke-subtle);
}

.table-clickable tbody tr {
  cursor: pointer;
}

.table-empty {
  text-align: center;
  padding: 32px 16px !important;
  color: var(--text-tertiary);
}

/* ── Detail Grid ───────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-tertiary);
}

.detail-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.detail-value code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  background: var(--stroke-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Action Buttons row ────────────────────────────────────────── */

.action-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ── Generated Codes ───────────────────────────────────────────── */

.generated-codes-list {
  margin-top: 24px;
}

.generated-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.generated-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.codes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface2);
  border-radius: var(--radius-xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ── Devices Grid ──────────────────────────────────────────────── */

.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.device-card {
  display: block;
  background: var(--bg-surface2);
  border-radius: var(--radius-4xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05);
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition-fast);
}

.device-card:hover {
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.08),
    0px 5px 1.5px -4px rgba(8, 8, 8, 0.5),
    0px 6px 4px -4px rgba(8, 8, 8, 0.05),
    0px 6px 13px 0px rgba(8, 8, 8, 0.12);
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.device-card-body {
  margin-bottom: 12px;
}

.device-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}

.device-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: -0.025em;
}

.device-card-footer {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 12px;
  border-top: 1px solid var(--stroke-subtle);
}

/* ── Status Dot ────────────────────────────────────────────────── */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot-green  { background: var(--color-green); }
.status-dot-red    { background: var(--color-red); }
.status-dot-yellow { background: var(--color-yellow); }
.status-dot-blue   { background: var(--color-blue); }
.status-dot-gray   { background: var(--text-tertiary); }

/* ── Toggle Group ──────────────────────────────────────────────── */

.toggle-group {
  display: inline-flex;
  gap: 4px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.toggle-btn {
  height: 48px;
  padding: 0 20px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.toggle-btn:hover {
  color: var(--text-primary);
}

.toggle-btn.active {
  border-color: var(--stroke-stroke2);
  color: var(--text-primary);
}

/* ── Filter Tabs ───────────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.filter-tab {
  height: 48px;
  padding: 0 20px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
}

.filter-tab:hover {
  color: var(--text-primary);
}

.filter-tab.active {
  border-color: var(--stroke-stroke2);
  color: var(--text-primary);
}

/* ── Audit Log Details ─────────────────────────────────────────── */

.log-details {
  background: var(--bg-surface2);
  border-radius: var(--radius-xl);
  box-shadow:
    inset 0 0 0 1.5px rgba(229, 229, 229, 0.04);
  padding: 16px 20px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
}

/* ── Toast (ui.js uses .show, CSS defined .active) ─────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-container .toast {
  position: relative;
  bottom: auto;
  right: auto;
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── Spinner wrap (ui.js) ──────────────────────────────────────── */

.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}

/* ── Modal .show alias ─────────────────────────────────────────── */

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-backdrop.show .modal {
  opacity: 1;
  transform: translateY(0);
}

/* ── Pagination ────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--stroke-subtle);
}

.pagination-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  letter-spacing: -0.02em;
}

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-dots {
  padding: 0 4px;
  color: var(--text-tertiary);
}

/* ── Text muted ────────────────────────────────────────────────── */

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

/* ── Error page ────────────────────────────────────────────────── */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  color: var(--text-secondary);
}

.error-page h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* ── Card header-right (ui.js card()) ──────────────────────────── */

.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Card body (ui.js card()) ──────────────────────────────────── */

.card-body {
  /* content wrapper inside card */
}

.card + .card {
  margin-top: 12px;
}

/* ── Progress Bar (ui.js progressBar()) ────────────────────────── */

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--stroke-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-blue);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
