/* ─── Google Fonts — Inter (Corporate, Legible, Professional) ─────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ─── CSS Custom Properties (Design Tokens) ─────────────────────────────────── */
:root {
  /* Brand */
  --brand-primary:     #2563EB;
  --brand-primary-dk:  #1A4FBB;
  --brand-primary-lt:  #EFF4FC;
  --brand-accent:      #0891B2;
  --brand-accent-lt:   #F0FAFA;

  /* Surfaces */
  --surface-0:         #FFFFFF;
  --surface-50:        #FAFBFC;
  --surface-100:       #F4F6F9;
  --surface-200:       #EAECF0;
  --surface-300:       #DDE1E8;

  /* Text */
  --text-primary:      #0F172A;
  --text-secondary:    #475569;
  --text-tertiary:     #94A3B8;
  --text-disabled:     #CBD5E1;
  --text-inverse:      #FFFFFF;
  --text-brand:        #2563EB;
  --text-link:         #2563EB;

  /* Borders */
  --border-light:      #E5E9EF;
  --border-default:    #D0D5DD;
  --border-dark:       #98A2B3;
  --border-brand:      #93C5FD;

  /* Status */
  --color-success:     #16A34A;
  --color-success-bg:  #F0FDF4;
  --color-success-bd:  #BBF7D0;
  --color-warning:     #D97706;
  --color-warning-bg:  #FFFBEB;
  --color-warning-bd:  #FDE68A;
  --color-danger:      #DC2626;
  --color-danger-bg:   #FEF2F2;
  --color-danger-bd:   #FECACA;
  --color-info:        #2563EB;
  --color-info-bg:     #EFF6FF;
  --color-info-bd:     #BFDBFE;

  /* Sidebar */
  --sidebar-width:     260px;
  --sidebar-mini:      64px;
  --sidebar-bg:        #0F172A;
  --sidebar-active:    #1E3A8A;
  --sidebar-hover:     rgba(255,255,255,0.06);
  --sidebar-text:      #94A3B8;
  --sidebar-text-act:  #FFFFFF;
  --sidebar-border:    rgba(255,255,255,0.06);
  --sidebar-accent:    #3B82F6;

  /* Header */
  --header-height:     60px;
  --header-bg:         #FFFFFF;
  --header-border:     #E5E9EF;

  /* Layout */
  --content-padding:   24px;
  --card-radius:       10px;
  --input-radius:      6px;
  --btn-radius:        6px;

  /* Transitions */
  --transition-fast:   100ms ease;
  --transition-base:   150ms ease;
  --transition-slow:   250ms ease;

  /* Typography */
  --font-sans:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:         'JetBrains Mono', 'Fira Code', monospace;
  --font-size-base:    13px;
  --line-height-base:  1.6;
  --letter-spacing:    -0.006em;
}

/* ─── Base Reset & Typography ────────────────────────────────────────────────── */
@layer base {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    letter-spacing: var(--letter-spacing);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
  }

  body {
    background-color: var(--surface-100);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'ss01' 1;
  }

  #root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* Headings */
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin: 0;
  }

  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 16px; }
  h4 { font-size: 14px; }
  h5 { font-size: 13px; }
  h6 { font-size: 12px; }

  p { margin: 0; }

  a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--transition-base);
  }
  a:hover { color: var(--brand-primary-dk); }

  /* Form elements */
  input, textarea, select, button {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
  }

  /* Remove default button styles */
  button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 99px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
  }

  /* Selection */
  ::selection {
    background: rgba(37, 99, 235, 0.15);
    color: var(--text-primary);
  }

  /* Focus ring */
  :focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: var(--input-radius);
  }

  /* Code */
  code, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
  }
}

/* ─── Component Layer ────────────────────────────────────────────────────────── */
@layer components {

  /* ── Layout Shell ─────────────────────────────────────────────────────── */
  .app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--surface-100);
  }

  .app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left var(--transition-slow);
    min-width: 0;
  }

  .app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--content-padding);
    scroll-behavior: smooth;
  }

  /* ── Sidebar ──────────────────────────────────────────────────────────── */
  .sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 40;
    transition: width var(--transition-slow);
    overflow: hidden;
    flex-shrink: 0;
  }

  .sidebar.collapsed {
    width: var(--sidebar-mini);
    min-width: var(--sidebar-mini);
  }

  .sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
  }

  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
  }

  .sidebar-nav::-webkit-scrollbar { width: 3px; }
  .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

  .sidebar-section {
    padding: 16px 12px 4px;
  }

  .sidebar-section-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148,163,184,0.5);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-slow);
    padding-left: 8px;
  }

  .sidebar.collapsed .sidebar-section-label {
    opacity: 0;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 1px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    letter-spacing: -0.005em;
  }

  .nav-item:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.85);
  }

  .nav-item.active {
    background: rgba(59,130,246,0.18);
    color: #93C5FD;
  }

  .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    background: #3B82F6;
    border-radius: 0 3px 3px 0;
  }

  .nav-item-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-slow), width var(--transition-slow);
  }

  .sidebar.collapsed .nav-item-label {
    opacity: 0;
    width: 0;
  }

  .nav-item-badge {
    background: rgba(239,68,68,0.2);
    color: #FCA5A5;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: opacity var(--transition-slow);
  }

  .sidebar.collapsed .nav-item-badge {
    opacity: 0;
  }

  .nav-item-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform var(--transition-base), opacity var(--transition-slow);
    opacity: 0.5;
  }

  .sidebar.collapsed .nav-item-chevron {
    opacity: 0;
  }

  .nav-item-chevron.open {
    transform: rotate(90deg);
  }

  /* Nav group children */
  .nav-children {
    overflow: hidden;
    transition: max-height var(--transition-slow) ease;
    max-height: 0;
  }

  .nav-children.open {
    max-height: 500px;
  }

  .nav-child-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px 7px 40px;
    margin: 1px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: all var(--transition-base);
    color: rgba(148,163,184,0.8);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 400;
    white-space: nowrap;
    letter-spacing: -0.005em;
  }

  .nav-child-item:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.8);
  }

  .nav-child-item.active {
    color: #93C5FD;
    background: rgba(59,130,246,0.12);
    font-weight: 500;
  }

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

  /* Sidebar tooltip (when collapsed) */
  .nav-tooltip {
    position: absolute;
    left: calc(var(--sidebar-mini) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1E293B;
    color: #E2E8F0;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
  }

  .nav-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1E293B;
  }

  /* ── Header ───────────────────────────────────────────────────────────── */
  .app-header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    flex-shrink: 0;
    z-index: 50;
    position: relative;
  }

  /* ── Cards ────────────────────────────────────────────────────────────── */
  .card {
    background: var(--surface-0);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: 20px;
    transition: box-shadow var(--transition-base);
  }

  .card-hover:hover {
    box-shadow: 0 4px 16px -2px rgba(16,24,40,0.10);
    border-color: var(--border-default);
  }

  .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--surface-200);
  }

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

  .card-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
  }

  /* Stat Card */
  .stat-card {
    background: var(--surface-0);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
  }

  .stat-card-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1;
    margin: 6px 0 4px;
  }

  .stat-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
  }

  .stat-card-trend {
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 6px;
  }

  .stat-card-trend.up   { color: var(--color-success); }
  .stat-card-trend.down { color: var(--color-danger); }
  .stat-card-trend.flat { color: var(--text-tertiary); }

  .stat-card-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Buttons ──────────────────────────────────────────────────────────── */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    border-radius: var(--btn-radius);
    padding: 8px 14px;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: -0.005em;
    user-select: none;
    position: relative;
    overflow: hidden;
  }

  .btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
  }

  .btn:active { transform: translateY(0.5px); }
  .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }

  /* Button variants */
  .btn-primary {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
  }
  .btn-primary:hover:not(:disabled) {
    background: var(--brand-primary-dk);
    border-color: var(--brand-primary-dk);
  }

  .btn-secondary {
    background: var(--surface-0);
    color: var(--text-primary);
    border-color: var(--border-default);
  }
  .btn-secondary:hover:not(:disabled) {
    background: var(--surface-100);
    border-color: var(--border-dark);
  }

  .btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
  }
  .btn-ghost:hover:not(:disabled) {
    background: var(--surface-100);
    color: var(--text-primary);
  }

  .btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
  }
  .btn-danger:hover:not(:disabled) {
    background: #B91C1C;
  }

  .btn-success {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
  }
  .btn-success:hover:not(:disabled) {
    background: #15803D;
  }

  .btn-outline-primary {
    background: transparent;
    color: var(--brand-primary);
    border-color: var(--border-brand);
  }
  .btn-outline-primary:hover:not(:disabled) {
    background: var(--color-info-bg);
  }

  /* Button sizes */
  .btn-xs   { padding: 5px 10px; font-size: 11px; }
  .btn-sm   { padding: 6px 12px; font-size: 12px; }
  .btn-md   { padding: 8px 14px; font-size: 13px; }
  .btn-lg   { padding: 10px 18px; font-size: 14px; }
  .btn-xl   { padding: 12px 22px; font-size: 15px; }
  .btn-icon { padding: 8px; width: 34px; height: 34px; }
  .btn-icon-sm { padding: 6px; width: 28px; height: 28px; }

  /* ── Form Elements ────────────────────────────────────────────────────── */
  .form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .form-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0;
  }

  .form-label.required::after {
    content: ' *';
    color: var(--color-danger);
  }

  .form-input {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--input-radius);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--surface-0);
    transition: all var(--transition-base);
    width: 100%;
    outline: none;
    letter-spacing: -0.005em;
  }

  .form-input:hover {
    border-color: var(--border-dark);
  }

  .form-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  }

  .form-input::placeholder {
    color: var(--text-disabled);
    font-weight: 400;
  }

  .form-input.error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.10);
  }

  .form-select {
    @apply form-input;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' 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 10px center;
    padding-right: 32px;
  }

  .form-textarea {
    @apply form-input;
    height: auto;
    padding: 10px 12px;
    resize: vertical;
    min-height: 80px;
  }

  .form-error {
    font-size: 11.5px;
    color: var(--color-danger);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
  }

  .form-hint {
    font-size: 11.5px;
    color: var(--text-tertiary);
    margin-top: 2px;
  }

  /* Search input */
  .search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
  }

  .search-input-wrap .search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-tertiary);
    pointer-events: none;
    width: 15px;
    height: 15px;
  }

  .search-input {
    @apply form-input;
    padding-left: 34px;
    background: var(--surface-50);
  }

  /* ── Tables ───────────────────────────────────────────────────────────── */
  .table-wrap {
    background: var(--surface-0);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    overflow: hidden;
  }

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

  .table thead {
    background: var(--surface-50);
    border-bottom: 1px solid var(--border-light);
  }

  .table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    border-right: none;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
  }

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

  .table td {
    padding: 12px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    font-weight: 400;
  }

  .table tbody tr:last-child td { border-bottom: none; }

  .table tbody tr {
    transition: background var(--transition-fast);
  }
  .table tbody tr:hover td {
    background: var(--surface-50);
  }

  /* Checkbox column */
  .table th:first-child,
  .table td:first-child {
    padding-left: 16px;
    width: 40px;
  }

  /* ── Badges ───────────────────────────────────────────────────────────── */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    line-height: 1.6;
  }

  .badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .badge-success { background: var(--color-success-bg); color: #15803D; }
  .badge-warning { background: var(--color-warning-bg); color: #B45309; }
  .badge-danger  { background: var(--color-danger-bg);  color: #B91C1C; }
  .badge-info    { background: var(--color-info-bg);    color: #1D4ED8; }
  .badge-neutral { background: var(--surface-200);      color: var(--text-secondary); }
  .badge-primary { background: var(--brand-primary-lt); color: var(--brand-primary); }

  /* ── Avatar ───────────────────────────────────────────────────────────── */
  .avatar {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--surface-200);
    color: var(--text-secondary);
    letter-spacing: 0;
  }

  .avatar-xs  { width: 24px; height: 24px; font-size: 9px; }
  .avatar-sm  { width: 28px; height: 28px; font-size: 10px; }
  .avatar-md  { width: 34px; height: 34px; font-size: 12px; }
  .avatar-lg  { width: 40px; height: 40px; font-size: 14px; }
  .avatar-xl  { width: 48px; height: 48px; font-size: 16px; }
  .avatar-2xl { width: 60px; height: 60px; font-size: 20px; }

  .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* ── Page Header ──────────────────────────────────────────────────────── */
  .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
  }

  .page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
  }

  .page-subtitle {
    font-size: 12.5px;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-weight: 400;
  }

  /* Breadcrumb */
  .breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
  }

  .breadcrumb-sep { color: var(--border-dark); }
  .breadcrumb-current { color: var(--text-secondary); font-weight: 500; }

  /* ── Tabs ─────────────────────────────────────────────────────────────── */
  .tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    gap: 0;
    margin-bottom: 20px;
  }

  .tab {
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-base);
    white-space: nowrap;
    letter-spacing: -0.005em;
  }

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

  .tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    font-weight: 600;
  }

  /* Pill tabs */
  .tabs-pill {
    display: flex;
    gap: 4px;
    background: var(--surface-100);
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
    margin-bottom: 20px;
  }

  .tab-pill {
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-base);
    white-space: nowrap;
  }

  .tab-pill.active {
    background: var(--surface-0);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }

  /* ── Skeleton Loading ─────────────────────────────────────────────────── */
  .skeleton {
    background: linear-gradient(90deg,
      var(--surface-200) 25%,
      var(--surface-100) 50%,
      var(--surface-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite linear;
    border-radius: 4px;
  }

  /* ── Dropdown ─────────────────────────────────────────────────────────── */
  .dropdown-menu {
    background: var(--surface-0);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 8px 24px -4px rgba(16,24,40,0.12), 0 4px 8px -2px rgba(16,24,40,0.06);
    padding: 4px;
    min-width: 180px;
    z-index: 70;
  }

  .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-weight: 400;
  }

  .dropdown-item:hover { background: var(--surface-100); }
  .dropdown-item.danger { color: var(--color-danger); }
  .dropdown-item.danger:hover { background: var(--color-danger-bg); }

  .dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
  }

  /* ── Modal ────────────────────────────────────────────────────────────── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(2px);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .modal {
    background: var(--surface-0);
    border-radius: 12px;
    box-shadow: 0 24px 64px -12px rgba(0,0,0,0.24);
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    animation: scale-in 150ms ease;
    border: 1px solid var(--border-light);
  }

  .modal-sm  { max-width: 400px; }
  .modal-md  { max-width: 560px; }
  .modal-lg  { max-width: 720px; }
  .modal-xl  { max-width: 900px; }
  .modal-2xl { max-width: 1100px; }

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

  .modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
  }

  .modal-body    { padding: 20px 24px; }
  .modal-footer  {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

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

  .empty-state-icon {
    width: 48px;
    height: 48px;
    background: var(--surface-100);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--text-tertiary);
  }

  .empty-state-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
  }

  .empty-state-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    max-width: 320px;
    line-height: 1.6;
  }

  /* ── Progress Bar ─────────────────────────────────────────────────────── */
  .progress {
    height: 6px;
    background: var(--surface-200);
    border-radius: 99px;
    overflow: hidden;
  }

  .progress-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--brand-primary);
    transition: width var(--transition-slow);
  }

  .progress-bar.success { background: var(--color-success); }
  .progress-bar.warning { background: var(--color-warning); }
  .progress-bar.danger  { background: var(--color-danger); }

  /* ── Tooltip ──────────────────────────────────────────────────────────── */
  [data-tooltip] {
    position: relative;
  }

  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1E293B;
    color: white;
    font-size: 11.5px;
    padding: 4px 8px;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    z-index: 80;
  }

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

  /* ── Divider ──────────────────────────────────────────────────────────── */
  .divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 0;
  }

  .divider-v {
    width: 1px;
    background: var(--border-light);
    align-self: stretch;
  }

  /* ── Alert ────────────────────────────────────────────────────────────── */
  .alert {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid;
    align-items: flex-start;
  }

  .alert-info    { background: var(--color-info-bg);    border-color: var(--color-info-bd);    color: #1D4ED8; }
  .alert-success { background: var(--color-success-bg); border-color: var(--color-success-bd); color: #15803D; }
  .alert-warning { background: var(--color-warning-bg); border-color: var(--color-warning-bd); color: #B45309; }
  .alert-danger  { background: var(--color-danger-bg);  border-color: var(--color-danger-bd);  color: #B91C1C; }

  .alert-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

  /* ── Pagination ───────────────────────────────────────────────────────── */
  .pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    background: var(--surface-50);
    border-radius: 0 0 var(--card-radius) var(--card-radius);
  }

  .page-btn {
    height: 30px;
    min-width: 30px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    letter-spacing: 0;
  }

  .page-btn:hover { background: var(--surface-200); color: var(--text-primary); }
  .page-btn.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
  }

  .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* ── Filters Bar ──────────────────────────────────────────────────────── */
  .filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
  }

  /* ── Role Color Indicators ────────────────────────────────────────────── */
  .role-badge-super-admin { @apply badge bg-purple-50 text-purple-700; }
  .role-badge-admin       { @apply badge bg-blue-50 text-blue-700; }
  .role-badge-faculty     { @apply badge bg-teal-50 text-teal-700; }
  .role-badge-student     { @apply badge bg-green-50 text-green-700; }
  .role-badge-parent      { @apply badge bg-orange-50 text-orange-700; }
  .role-badge-alumni      { @apply badge bg-indigo-50 text-indigo-700; }
}

/* ─── Utility Layer ──────────────────────────────────────────────────────────── */
@layer utilities {
  .text-balance    { text-wrap: balance; }
  .truncate-2      { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .truncate-3      { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
  .no-scrollbar::-webkit-scrollbar { display: none; }
  .no-scrollbar    { -ms-overflow-style: none; scrollbar-width: none; }
  .grid-flow-dense { grid-auto-flow: dense; }
  .aspect-golden   { aspect-ratio: 1.618 / 1; }
  .perspective     { perspective: 1000px; }
  .preserve-3d     { transform-style: preserve-3d; }
  .backface-hidden { backface-visibility: hidden; }
  .text-mono       { font-family: var(--font-mono); }
}

/* ─── Print styles ───────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .app-header, .no-print { display: none !important; }
  .app-content { margin-left: 0 !important; }
  .app-main { padding: 0 !important; }
  .card { border: 1px solid #ddd !important; box-shadow: none !important; }
}

/* ── Missing additions ──────────────────────────────────────────────────── */
.header {
  height: var(--header-height);
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

:root {
  --color-info-bg:  #EFF6FF;
  --color-info-bd:  #BFDBFE;
  --color-info-text:#1D4ED8;
  --color-success-bg:#F0FDF4;
  --color-success-bd:#BBF7D0;
  --color-warning-bg:#FFFBEB;
  --color-warning-bd:#FDE68A;
  --color-danger-bg: #FEF2F2;
  --color-danger-bd: #FECACA;
}

.spin-slow { animation: spin-slow 1s linear infinite; }

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.w-full { width: 100%; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }

/* Service cards */
.service-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-light);
  background: var(--surface-0);
  cursor: pointer;
  transition: all 150ms;
  text-decoration: none;
  color: var(--text-primary);
}
.service-card:hover {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 0 0 20px 0;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 32px;
  bottom: 0;
  width: 1px;
  background: var(--border-light);
}
.timeline-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
