/* ============================================================
   Amkor Coop — Data Management System
   Palette: blush pink header/sidebar, rose interactive accent,
   soft cream-white content surfaces, mauve ink text.
   Supports light (default) and dark themes via [data-theme="dark"].
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Palette (light theme / default) ---- */
  --ink:          #5B3A46;   /* primary text / headers — deep mauve */
  --ink-soft:     #8C6472;   /* secondary text */
  --ink-faint:    #7A5860;   /* tertiary / placeholder — AA on white & paper */

  --paper:        #FDF1F5;   /* page background — blush pink */
  --paper-card:   #FFFFFF;   /* card / panel surface */
  --paper-raised: #FFFFFF;   /* inputs, popped surfaces */

  --pink:         #F6C7DC;   /* sidebar / header pink */
  --pink-soft:    #FBE0EB;   /* sidebar tint / soft backgrounds */
  --pink-deep:    #F0AFCB;   /* header gradient end */

  --accent:       #A44267;   /* rose — primary interactive (buttons, links) */
  --accent-hover: #8B2E50;
  --accent-soft:  #FBE0EB;   /* rose tint for backgrounds */
  --accent-2:     #8B2E50;   /* deeper rose — active/emphasis */
  --accent-2-soft:#F6D3E1;

  --gold:         #D4A64A;   /* secondary accent for variety (quick actions) */
  --gold-soft:    #F4E9D3;

  --green:        #4C8B6B;   /* status-active green (functional, kept muted) */
  --green-soft:   #DEEBE3;

  --danger:       #A33B32;
  --danger-soft:  #F1DCD8;

  --border:       #F0C8D9;   /* hairline pink-tinted border */
  --border-soft:  #F6DEE9;

  /* ---- Icon chip palette (Soft Pink / Cotton Candy / Pink / Bordeaux) ----
     Used for quick-action + stat-tile icon circles so they read as one
     cohesive "cutie" pink family instead of mixed green/gold/purple. */
  --icon-1-bg: #FEF1F7;  /* Soft Pink */
  --icon-1-fg: #C85480;

  --icon-2-bg: #FFC9E2;  /* Cotton Candy */
  --icon-2-fg: #A8406A;

  --icon-3-bg: #EA8EAB;  /* Pink */
  --icon-3-fg: #5A0016;

  --icon-4-bg: #5A0016;  /* Bordeaux */
  --icon-4-fg: #FFDDE8;

  /* ---- Buttons: pink solid + pink outline (no white buttons) ---- */
  --btn-outline-bg:        #FDEEF4;
  --btn-outline-bg-hover:  #FBE0EB;
  --btn-outline-border:    #F0AFCB;
  --btn-outline-text:      #8B2E50;

  /* ---- Type ---- */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 2px rgba(91, 58, 70, 0.06), 0 1px 1px rgba(91, 58, 70, 0.04);
  --shadow-raised: 0 6px 20px rgba(91, 58, 70, 0.12), 0 2px 6px rgba(91, 58, 70, 0.08);
}

/* ============================================================
   DARK THEME — activated by <html data-theme="dark">
   ============================================================ */
[data-theme="dark"] {
  --ink:          #F3E6EB;
  --ink-soft:     #C9A8B4;
  --ink-faint:    #BDAAB6;   /* tertiary / placeholder — AA on both dark surfaces */

  --paper:        #211820;
  --paper-card:   #2B2029;
  --paper-raised: #332631;

  --pink:         #3D2A38;
  --pink-soft:    #34242F;
  --pink-deep:    #4A3242;

  --accent:       #E792AF;
  --accent-hover: #F0AAC2;
  --accent-soft:  rgba(231, 146, 175, 0.16);
  --accent-2:     #E0A6C4;
  --accent-2-soft:rgba(224, 166, 196, 0.16);

  --gold:         #E0B863;
  --gold-soft:    rgba(224, 184, 99, 0.16);

  --green:        #7FBFA0;
  --green-soft:   rgba(127, 191, 160, 0.16);

  --danger:       #E29089;
  --danger-soft:  rgba(226, 144, 137, 0.18);

  --border:       #45303F;
  --border-soft:  #3A2836;

  /* Keep the icon chips as true pastel/bordeaux swatches even in dark mode —
     they pop nicely against dark cards, same as the reference palette. */
  --icon-1-bg: rgba(254,241,247,0.15);
  --icon-1-fg: #F0AAC2;

  --icon-2-bg: rgba(255,201,226,0.15);
  --icon-2-fg: #E8A0C8;

  --icon-3-bg: rgba(234,142,171,0.15);
  --icon-3-fg: #F0AAC2;

  --icon-4-bg: rgba(90,0,22,0.5);
  --icon-4-fg: #FFDDE8;

  /* ---- Buttons in dark mode: pink-tinted, never white ---- */
  --btn-outline-bg:        #3A2836;
  --btn-outline-bg-hover:  #45303F;
  --btn-outline-border:    #5C3F52;
  --btn-outline-text:      #F0AAC2;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-raised: 0 6px 20px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Smooth transition when switching themes */
body, .app-shell .sidebar, .app-shell .topbar, .panel, .stat-tile,
.quick-action, .login-card, .user-menu-trigger, .user-menu-dropdown,
.form-group input, .form-group select, .form-group textarea, .btn {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ============================================================
   MODAL / OVERLAY  — global themed CSS variables
   Every modal/dialog uses these instead of hard-coded hex values
   so both light and dark themes switch consistently.
   ============================================================ */
:root {
  --modal-overlay-bg:      rgba(60, 20, 45, 0.45);
  --modal-bg:              #FFFFFF;
  --modal-border:          var(--border);
  --modal-text:            var(--ink);
  --modal-text-soft:       var(--ink-soft);
  --modal-text-faint:      var(--ink-faint);
  --modal-input-bg:        var(--paper-raised);
  --modal-input-border:    var(--border);
  --modal-input-text:      var(--ink);
  --modal-input-placeholder: var(--ink-faint);
  --modal-chip-bg:         var(--accent-soft);
  --modal-chip-text:       var(--accent-2);
  --modal-header-border:   var(--border-soft);
  --modal-footer-border:   var(--border-soft);
  --modal-suggestion-bg:   var(--paper-card);
  --modal-suggestion-hover:var(--accent-soft);
  --modal-suggestion-text: var(--ink);
  --modal-close-bg:        var(--paper-raised);
  --modal-close-text:      var(--ink-soft);
  --modal-close-hover:     var(--accent-soft);
  --modal-shadow:          0 20px 60px rgba(91, 58, 70, 0.22), 0 4px 16px rgba(91, 58, 70, 0.12);
}

[data-theme="dark"] {
  --modal-overlay-bg:      rgba(10, 5, 10, 0.62);
  --modal-bg:              var(--paper-card);    /* #2B2029 */
  --modal-border:          var(--border);
  --modal-text:            var(--ink);
  --modal-text-soft:       var(--ink-soft);
  --modal-text-faint:      var(--ink-faint);
  --modal-input-bg:        var(--paper-raised);
  --modal-input-border:    var(--border);
  --modal-input-text:      var(--ink);
  --modal-input-placeholder: var(--ink-faint);
  --modal-chip-bg:         var(--accent-soft);
  --modal-chip-text:       var(--accent);
  --modal-header-border:   var(--border);
  --modal-footer-border:   var(--border);
  --modal-suggestion-bg:   var(--paper-raised);
  --modal-suggestion-hover:var(--accent-soft);
  --modal-suggestion-text: var(--ink);
  --modal-close-bg:        rgba(255, 255, 255, 0.07);
  --modal-close-text:      var(--ink-soft);
  --modal-close-hover:     rgba(255, 255, 255, 0.13);
  --modal-shadow:          0 20px 60px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(165deg, var(--pink-soft) 0%, var(--pink) 40%, var(--pink-deep) 75%, var(--paper) 100%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

[data-theme="dark"] html,
[data-theme="dark"] body {
  background: linear-gradient(165deg, var(--pink-soft) 0%, var(--pink) 40%, #1a1017 100%);
}

/* Floating blur orbs — same treatment as the login screen, now global */
body {
  position: relative;
}

body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
  pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #FFFFFF 0%, var(--accent) 45%, var(--pink-deep) 100%);
  z-index: 0;
}
body::before { width: 340px; height: 340px; top: -90px; left: -110px; }
body::after  { width: 260px; height: 260px; bottom: -80px; right: -60px; opacity: 0.4; }

/* ---- App shell ---- */
.app-shell {
  background: transparent;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.app-shell .content,
.app-shell main.content {
  background: transparent;
  grid-column: 2;
  grid-row: 2;
  padding: 24px 32px 32px;
}

/* ---- Sidebar (soft pink, matches screenshot) ---- */
.app-shell .sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--pink);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
}

.app-shell .sidebar .brand {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(91, 58, 70, 0.12);
}

.app-shell .sidebar .brand-logo {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.app-shell .sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-shell .sidebar nav a {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: #7D3255;   /* 5.74:1 on --pink #F6C7DC — AA compliant */
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid rgba(91, 58, 70, 0.08);
}

/* Dark mode nav links: use --accent-hover which is already light enough */
[data-theme="dark"] .app-shell .sidebar nav a {
  color: var(--accent-hover);  /* #F0AAC2 — 7.08:1 on #3D2A38 */
}

.app-shell .sidebar nav a:hover,
.app-shell .sidebar nav a.active {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
}

[data-theme="dark"] .app-shell .sidebar nav a:hover,
[data-theme="dark"] .app-shell .sidebar nav a.active {
  background: rgba(255, 255, 255, 0.08);
}

.app-shell .sidebar nav a.active {
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}

/* ---- Topbar (header band, pink gradient) ---- */
.app-shell .topbar {
  grid-column: 2;
  grid-row: 1;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 18px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

.topbar-spacer {
  flex: 1;
}

.topbar-title {
  flex: 2;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-transform: uppercase;
}

.topbar-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper-card);
}

.logout-top { width: auto; }

/* ---- Theme toggle button ---- */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paper-card);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 16px;
  color: var(--ink-soft);
  padding: 0;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--accent-soft);
}

/* ---- User menu dropdown ---- */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
  font-family: var(--font-body);
}

.user-menu-trigger:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.user-menu-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-menu-avatar--lg {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.user-menu-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}

.user-menu-caret {
  font-size: 10px;
  color: var(--ink-faint);
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 14px;
  z-index: 50;
}

.user-menu-dropdown.open {
  display: block;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 10px;
}

.user-menu-fullname {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.user-menu-role {
  font-size: 12px;
  color: var(--ink-faint);
}

.user-menu-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}

.user-menu-item:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.user-menu-item-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.user-menu-item--danger:hover {
  background: var(--danger-soft);
  color: #7C2C25;
}

[data-theme="dark"] .user-menu-item--danger:hover {
  color: #FFD9D4;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .app-shell .sidebar {
    grid-column: 1;
    grid-row: 2;
  }
  .app-shell .topbar {
    grid-column: 1;
    grid-row: 1;
    flex-wrap: wrap;
    gap: 10px;
  }
  .app-shell .content {
    grid-column: 1;
    grid-row: 3;
  }
  .topbar-title {
    order: 3;
    flex-basis: 100%;
    text-align: left;
  }
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 4px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.subtitle {
  color: var(--ink-soft);
  font-size: 14px;
}

.field-hint {
  color: var(--ink-faint);
  font-size: 13px;
}

/* ============================================================
   LOGIN SCREEN (top pink header + sidebar + centered card,
   matching the actual screenshot layout)
   ============================================================ */

.login-page-shell {
  min-height: 100vh;
  background: var(--paper);
}

.login-header {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-deep) 100%);
  padding: 22px 40px 34px;
  position: relative;
}

.login-header .brand-logo {
  height: 58px;
  display: block;
}

.login-tagline {
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 6px;
}

.login-body-split {
  display: flex;
  min-height: calc(100vh - 116px);
}

.login-sidebar {
  width: 200px;
  background: var(--pink);
  padding: 28px 22px;
  flex-shrink: 0;
}

.login-sidebar a {
  display: block;
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 14px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(91, 58, 70, 0.12);
}
.login-sidebar a:hover { color: var(--ink); }

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
}

/* legacy split-shell kept for compatibility with older markup */
.login-split-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

@media (max-width: 860px) {
  .login-split-shell { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-body-split { flex-direction: column; }
  .login-sidebar { display: none; }
}

.login-brand-panel {
  background: linear-gradient(160deg, var(--pink) 0%, var(--pink-deep) 100%);
  color: var(--ink);
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.login-brand-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-hover);
  margin-bottom: 28px;
}

.login-brand-panel h1 {
  color: var(--ink);
  font-size: 34px;
  line-height: 1.2;
  max-width: 460px;
  margin-bottom: 18px;
}

.login-brand-panel p {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 420px;
  margin: 0 0 30px;
}

.login-brand-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-brand-list li {
  position: relative;
  padding-left: 22px;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-brand-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

.login-form-panel {
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

/* ---- Sign-in card, matching screenshot exactly ---- */
.login-form-inner,
.login-card {
  width: 100%;
  max-width: 340px;
}

.login-card {
  background: var(--paper-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  border: 1px solid var(--border);
  overflow: hidden;
}

.login-card-header {
  background: var(--accent);
  color: #FFFFFF;
  text-align: center;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.login-card-body {
  padding: 30px 30px 26px;
}

.login-form-inner h2 {
  font-size: 26px;
  margin-bottom: 6px;
}

.login-form-inner .subtitle {
  margin-bottom: 28px;
}

.login-form-footnote,
.login-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
}

.login-register {
  text-align: center;
  font-size: 13px;
  margin-top: 18px;
  color: var(--ink-soft);
}

.login-register a {
  color: var(--accent-hover);
  font-weight: 800;
}
.login-register a:hover { text-decoration: underline; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group {
  margin-bottom: 18px;
}

/* Two-column form layout — collapses to 1-col at ≤860px via responsive block */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 22px;
}

.form-grid .form-group.full,
.form-grid .full {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Textarea: auto-height hint, comfortable minimum, no horizontal resize */
.form-group textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

/* ── Upload dropzone ─────────────────────────────────────────────────── */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  background: var(--paper-raised);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.dropzone:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.dropzone.dragover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  /* ensure the invisible input stays above .dropzone-content */
  z-index: 1;
}

.dropzone-content {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone-icon {
  font-size: 2rem;
  line-height: 1;
}

.dropzone-text {
  pointer-events: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.dropzone-subtext {
  font-size: 0.82rem;
  color: var(--ink-faint);
  pointer-events: none;
}

.dropzone-filename {
  display: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  pointer-events: none;
  word-break: break-all;
}

.dropzone.has-file .dropzone-text { display: none; }
.dropzone.has-file .dropzone-subtext { display: none; }
.dropzone.has-file .dropzone-filename { display: block; }
.dropzone.has-file .dropzone-icon { color: var(--accent); }

/* Base reset: catches ANY plain text-like input/select/textarea that
   isn't wrapped in .form-group (e.g. a standalone search box), so it
   still gets themed background/border instead of browser-default white. */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="date"],
textarea,
select {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #E3B7B0;
  color: #7C2C25;
}

[data-theme="dark"] .alert-danger {
  color: #FFD9D4;
  border-color: #6B3A34;
}

.alert-success {
  background: var(--green-soft);
  border-color: #BFDACD;
  color: #235A46;
}

[data-theme="dark"] .alert-success {
  background: rgba(75, 139, 107, 0.18);
  color: #B9E5CE;
  border-color: #3E6350;
}

.alert-info {
  background: var(--accent-soft);
  border-color: var(--btn-outline-border);
  color: var(--accent-2);
}

[data-theme="dark"] .alert-info {
  background: rgba(231, 146, 175, 0.14);
  color: #F5C8DB;
  border-color: #6B3C51;
}

.alert-warning {
  background: var(--gold-soft);
  border-color: #E3CFA0;
  color: #7A5A22;
}

[data-theme="dark"] .alert-warning {
  background: rgba(224, 184, 99, 0.16);
  color: #F0DBA6;
  border-color: #6B5730;
}

/* ============================================================
   BUTTONS
   All buttons are pink — solid accent or pink-tinted outline.
   No white/neutral button backgrounds in either theme.
   ============================================================ */

/* Base reset: catches ANY plain <button> / submit input that has no
   .btn class (e.g. a lone "Delete" button inside a form). Low
   specificity on purpose — any .btn-* class below still wins. */
button,
input[type="submit"],
input[type="button"] {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-outline-border);
  background: var(--btn-outline-bg);
  color: var(--btn-outline-text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--btn-outline-bg-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  /* box-sizing ensures padding + border never expand beyond declared size */
  box-sizing: border-box;
  /* width: auto by default — only full-width when explicitly needed */
  width: auto;
  /* overflow:hidden clips content to the border-box, preventing hover
     outline/background from bleeding outside the button boundary */
  overflow: hidden;
  /* Consistent height so buttons on the same row always align */
  min-height: 40px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  /* Contain the :hover background strictly inside the border-radius */
  isolation: isolate;
}

/* Full-width variant — opt-in with .btn-block */
.btn-block { width: 100%; }

.btn:active { transform: translateY(1px); }

.btn-accent,
.btn-signin {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-accent:hover,
.btn-signin:hover {
  background: var(--accent-hover);
  color: #FFFFFF;
}

.btn-outline {
  background: var(--btn-outline-bg);
  color: var(--btn-outline-text);
  border-color: var(--btn-outline-border);
}
.btn-outline:hover {
  background: var(--btn-outline-bg-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 13px;
  min-height: 32px;
}

/* Generic safety net: catch any other/legacy button variants
   (e.g. .btn-light, .btn-white, .btn-default, .btn-secondary)
   so nothing renders as a plain white button in either theme. */
.btn-light,
.btn-white,
.btn-default,
.btn-secondary {
  background: var(--btn-outline-bg);
  color: var(--btn-outline-text);
  border: 1px solid var(--btn-outline-border);
}
.btn-light:hover,
.btn-white:hover,
.btn-default:hover,
.btn-secondary:hover {
  background: var(--btn-outline-bg-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* Form action row — contains submit + cancel buttons side by side */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 { font-size: 25px; }

.header-actions {
  display: flex;
  gap: 10px;
}

/* ============================================================
   QUICK ACTIONS
   ============================================================ */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.quick-action::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0.7;
}

.quick-action:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-raised);
  border-color: var(--accent);
  color: var(--ink);
}

.quick-action-icon {
  font-size: 22px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--icon-1-bg);
  color: var(--icon-1-fg);
}

/* rotate through the Soft Pink / Cotton Candy / Pink / Bordeaux family */
.quick-action:nth-child(4n+1) .quick-action-icon { background: var(--icon-1-bg); color: var(--icon-1-fg); }
.quick-action:nth-child(4n+2) .quick-action-icon { background: var(--icon-2-bg); color: var(--icon-2-fg); }
.quick-action:nth-child(4n+3) .quick-action-icon { background: var(--icon-3-bg); color: var(--icon-3-fg); }
.quick-action:nth-child(4n+4) .quick-action-icon { background: var(--icon-4-bg); color: var(--icon-4-fg); }

/* ============================================================
   GRID / STAT TILES
   ============================================================ */

.grid {
  display: grid;
  gap: 16px;
}

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

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}

.stat-tile {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.stat-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 46px;
  height: 4px;
  border-radius: 0 0 3px 0;
  background: var(--accent);
}

.stat-tile[data-accent="a"]::before { background: var(--icon-1-fg); }
.stat-tile[data-accent="b"]::before { background: var(--icon-2-fg); }
.stat-tile[data-accent="c"]::before { background: var(--icon-3-fg); }
.stat-tile[data-accent="d"]::before { background: var(--icon-4-fg); }

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  margin-bottom: 10px;
  background: var(--icon-1-bg);
  color: var(--icon-1-fg);
}

.stat-tile[data-accent="a"] .stat-icon { background: var(--icon-1-bg); color: var(--icon-1-fg); }
.stat-tile[data-accent="b"] .stat-icon { background: var(--icon-2-bg); color: var(--icon-2-fg); }
.stat-tile[data-accent="c"] .stat-icon { background: var(--icon-3-bg); color: var(--icon-3-fg); }
.stat-tile[data-accent="d"] .stat-icon { background: var(--icon-4-bg); color: var(--icon-4-fg); }

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ============================================================
   PANELS
   ============================================================ */

.panel {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}

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

.panel-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  margin: 0 0 4px;
  flex: 1;
}

.panel-header .panel-title { border-bottom: none; margin-bottom: 0; }

/* ============================================================
   TABLE
   ============================================================ */

/* Bare <table> inside a .panel inherits compact styles automatically */
.panel > table,
.panel table.table-compact {
  width: 100%;
}

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

.table-compact thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}

.table-compact tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
  vertical-align: middle;
}

.table-compact tbody tr:last-child td { border-bottom: none; }
.table-compact tbody tr:hover td { background: var(--accent-soft); }

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

.badge-missing-file {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: #b45309;
  background: #fef3e2;
  border: 1px solid #fbd38d;
  border-radius: 12px;
  padding: 3px 10px;
  white-space: nowrap;
}
[data-theme="dark"] .badge-missing-file {
  color: #fbbf24;
  background: #3c2f10;
  border-color: #5c4620;
}

.truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.truncate-wide { max-width: 320px; }

.mono-sm {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.empty-state {
  text-align: center;
  padding: 48px 20px 40px;
  color: var(--ink-faint);
  font-size: 13.5px;
}

.empty-state::before {
  content: attr(data-icon);
  display: block;
  font-size: 32px;
  margin-bottom: 10px;
  line-height: 1;
}

/* fallback icon when data-icon not set */
td.empty-state:not([data-icon])::before {
  content: "📂";
}

/* ============================================================
   ACTION PILLS (log actions)
   ============================================================ */

.action-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--paper-raised);
  color: var(--ink-soft);
  border-color: var(--border);
}

.action-login,
.action-create,
.action-add,
.action-member_added,
.action-memberadded { background: var(--green-soft); color: #235A46; border-color: #BFDACD; }

.action-update,
.action-edit,
.action-doc_upload,
.action-docupload    { background: var(--gold-soft);    color: #7A5A22; border-color: #E3CFA0; }

.action-delete,
.action-remove { background: var(--danger-soft);   color: #7C2C25; border-color: #E3B7B0; }

.action-logout,
.action-view,
.action-download,
.action-upload { background: var(--accent-soft);   color: var(--accent-hover); border-color: #F0BFD6; }

.action-backup,
.action-restore,
.action-backup_created,
.action-backupcreated { background: var(--accent-2-soft); color: #8A3D5D; border-color: #EBC0D3; }

[data-theme="dark"] .action-login,
[data-theme="dark"] .action-create,
[data-theme="dark"] .action-add,
[data-theme="dark"] .action-member_added,
[data-theme="dark"] .action-memberadded { color: #B9E5CE; border-color: #3E6350; }

[data-theme="dark"] .action-update,
[data-theme="dark"] .action-edit,
[data-theme="dark"] .action-doc_upload,
[data-theme="dark"] .action-docupload { color: #F0DBA6; border-color: #6B5730; }

[data-theme="dark"] .action-delete,
[data-theme="dark"] .action-remove { color: #FFD9D4; border-color: #6B3A34; }

[data-theme="dark"] .action-logout,
[data-theme="dark"] .action-view,
[data-theme="dark"] .action-download,
[data-theme="dark"] .action-upload { color: #F5C8DB; border-color: #6B3C51; }

[data-theme="dark"] .action-backup,
[data-theme="dark"] .action-restore,
[data-theme="dark"] .action-backup_created,
[data-theme="dark"] .action-backupcreated { color: #EFC3DC; border-color: #6A3E56; }

/* ============================================================
   BADGES (member status etc.)
   ============================================================ */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-active   { background: var(--green-soft); color: #235A46; border-color: #BFDACD; }
.badge-inactive { background: var(--danger-soft);   color: #7C2C25; border-color: #E3B7B0; }

.badge-confidential {
  background: var(--danger-soft);
  color: #7C2C25;
  border-color: #E3B7B0;
  font-size: 11.5px;
}

[data-theme="dark"] .badge-confidential {
  background: rgba(163, 59, 50, 0.18);
  color: #FFD9D4;
  border-color: #6B3A34;
}

.badge-storage {
  background: var(--gold-soft);
  color: #7A5A22;
  border-color: #E3CFA0;
  font-size: 11.5px;
  font-family: var(--font-mono);
}

[data-theme="dark"] .badge-storage {
  background: rgba(224, 184, 99, 0.16);
  color: #F0DBA6;
  border-color: #6B5730;
}

[data-theme="dark"] .badge-active   { color: #B9E5CE; border-color: #3E6350; }
[data-theme="dark"] .badge-inactive { color: #FFD9D4; border-color: #6B3A34; }

/* ============================================================
   BREAKDOWN BARS
   ============================================================ */

.breakdown-row {
  display: grid;
  grid-template-columns: 90px 1fr 30px;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}

.breakdown-row + .breakdown-row {
  border-top: 1px solid var(--border-soft);
}

.breakdown-label {
  font-size: 13px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-bar-track {
  height: 8px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}

.breakdown-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.breakdown-count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

/* ============================================================
   LAYOUT WRAPPER
   ============================================================ */

.app-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}


/* ============================================================
   Row Action Menu (3-dot) — Documents page
   ============================================================ */
.row-menu-wrap { position: relative; display: inline-block; }
.row-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--ink-soft);
}
.row-menu-btn:hover { background: var(--accent-soft); }
.row-menu {
  display: none;
  position: fixed;   /* escapes any overflow/stacking context */
  /* top / left set by JS (_positionDropdown) */
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-raised);
  min-width: 200px;
  z-index: 9999;
  padding: 6px 0;
  text-align: left;
}
.row-menu.open { display: block; }
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.88rem;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}
.row-menu-item:hover { background: var(--accent-soft); }
.row-menu-icon { width: 18px; display: inline-block; text-align: center; flex-shrink: 0; }
.row-menu-divider { height: 1px; background: var(--border-soft); margin: 4px 0; }
.row-menu-disabled { opacity: 0.5; cursor: default; }
.row-menu-disabled:hover { background: none; }
.row-menu-danger { color: var(--danger); }
.row-menu-danger:hover { background: var(--danger-soft); }

/* Prevent .panel's overflow:hidden / overflow-x:auto from clipping
   position:absolute dropdowns.  The overflow only needs to activate
   when a table is wider than its container, not at the panel level. */
.panel { overflow: visible; }
.panel-table-wrap { overflow-x: auto; }


/* ============================================================
   Version badge  (standardised — replaces one-off inline styles)
   ============================================================ */
.badge-version {
  display: inline-flex;
  align-items: center;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.4;
  border: 1px solid var(--btn-outline-border);
}

[data-theme="dark"] .badge-version {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(231, 146, 175, 0.3);
}


/* ============================================================
   Drive / Document table  (shared across pages)
   ============================================================ */
.drive-table {
  width: 100%;
  border-collapse: collapse;
}

.drive-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.drive-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  color: var(--ink);
  vertical-align: middle;
}

.drive-table tbody tr:last-child td { border-bottom: none; }
.drive-table tbody tr:hover td { background: var(--accent-soft); }

/* name cell: icon + text side by side.
   Use an inner wrapper div for flex rather than styling <td> directly —
   display:flex on a <td> can break row height alignment in some browsers. */
.drive-name-cell {
  /* td itself: normal table-cell layout */
}

.drive-name-cell-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Keep backward-compat: if code uses drive-name-cell as the flex container */
td.drive-name-cell {
  /* vertical-align already set by tbody td rule */
}

.drive-name-text {
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.drive-table tbody tr:hover .drive-name-text { text-decoration: underline; }

/* owner cell: avatar + name */
.gdrive-owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.gdrive-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}

/* file-type coloured square */
.gdrive-ficon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}


/* ============================================================
   Unified document-list toolbar
   ============================================================ */
.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* All children share the same height baseline */
.doc-toolbar input[type="text"],
.doc-toolbar input[type="search"],
.doc-toolbar select {
  height: 40px;
  padding: 0 12px;
  font-size: 13.5px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.doc-toolbar input[type="text"]:focus,
.doc-toolbar input[type="search"]:focus,
.doc-toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* search input fills available space */
.doc-toolbar .doc-toolbar-search {
  flex: 1;
  min-width: 180px;
}

/* selects are fixed width */
.doc-toolbar select {
  min-width: 120px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238C6472' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ---- push the Clear button to the right ---- */
.doc-toolbar .doc-toolbar-spacer { flex: 1; }

@media (max-width: 640px) {
  .doc-toolbar { gap: 6px; }
  .doc-toolbar input[type="text"],
  .doc-toolbar input[type="search"],
  .doc-toolbar select { height: 38px; font-size: 13px; }
  .doc-toolbar .doc-toolbar-search { min-width: 100%; flex-basis: 100%; }
}


/* ── Drive/document three-dot action menu ─────────────────────────── */
/* position:fixed lets the dropdown escape overflow/stacking contexts    */
/* on tables, CSS-grid rows, and panels.  top/left are set by JS.        */

.drive-menu-cell {
  position: relative;   /* anchor for the ⋮ button only; menu uses fixed */
  text-align: right;
}

.drive-kebab-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--ink-soft);
  line-height: 1;
}
.drive-kebab-btn:hover { background: var(--accent-soft); }

.drive-dropdown-menu {
  display: none;
  position: fixed;    /* JS (_positionDropdown) sets top + left */
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-raised);
  min-width: 200px;
  z-index: 9999;
  padding: 6px 0;
  text-align: left;
}
.drive-dropdown-menu.open { display: block; }

.drive-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.1s;
}
.drive-dropdown-item:hover        { background: var(--accent-soft); }
.drive-dropdown-item--danger      { color: var(--danger); }
.drive-dropdown-item--danger:hover{ background: var(--danger-soft); }

.drive-dropdown-icon {
  width: 18px;
  display: inline-block;
  text-align: center;
  flex-shrink: 0;
}

.drive-dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 0;
}


/* ── Color Theme Picker ──────────────────────────────────────────────── */
.color-picker-wrap { position: relative; }
.color-picker-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-raised);
  padding: 14px 16px;
  z-index: 100;
  min-width: 180px;
}
.color-picker-dropdown.open { display: block; }
.color-picker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.color-picker-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--ink); transform: scale(1.15); }

/* ---- Color Theme Overrides ---- */
/* Each theme tunes accent + sidebar colors AND the icon chip palette
   so stat-tile/quick-action icons stay readable against the new accent. */
[data-color="blue"] {
  --accent: #4472C4;
  --accent-hover: #365FA0;
  --accent-soft: #E8F0FE;
  --pink: #D6E4F7;
  --pink-soft: #EBF2FB;
  --pink-deep: #B8D4F0;
  --border: #B8D4F0;
  --border-soft: #D6E4F7;
  --icon-1-bg: #E8F0FE; --icon-1-fg: #1A4FA8;
  --icon-2-bg: #BFCFEE; --icon-2-fg: #0F3075;
  --icon-3-bg: #90ABE0; --icon-3-fg: #06235A;
  --icon-4-bg: #0A2A6E; --icon-4-fg: #D0DCFA;
}
[data-color="green"] {
  --accent: #70AD47;
  --accent-hover: #5A8C38;
  --accent-soft: #E8F5E0;
  --pink: #D4EDCB;
  --pink-soft: #EAF7E4;
  --pink-deep: #B8DFA8;
  --border: #B8DFA8;
  --border-soft: #D4EDCB;
  --icon-1-bg: #E8F5E0; --icon-1-fg: #2E6B1A;
  --icon-2-bg: #BFDFAB; --icon-2-fg: #1A4A08;
  --icon-3-bg: #8FC478; --icon-3-fg: #0E3003;
  --icon-4-bg: #1A4A08; --icon-4-fg: #D0EFC4;
}
[data-color="purple"] {
  --accent: #7C3AED;
  --accent-hover: #6429C9;
  --accent-soft: #EDE9FE;
  --pink: #DDD6FE;
  --pink-soft: #EDE9FE;
  --pink-deep: #C4B5FD;
  --border: #C4B5FD;
  --border-soft: #DDD6FE;
  --icon-1-bg: #EDE9FE; --icon-1-fg: #4C1D9A;
  --icon-2-bg: #C4B5FD; --icon-2-fg: #2E0F6E;
  --icon-3-bg: #9C7EF5; --icon-3-fg: #1A0644;
  --icon-4-bg: #2E0F6E; --icon-4-fg: #DDD6FE;
}
[data-color="orange"] {
  --accent: #ED7D31;
  --accent-hover: #C96522;
  --accent-soft: #FEF0E5;
  --pink: #FDDCBF;
  --pink-soft: #FEF0E5;
  --pink-deep: #FACBA0;
  --border: #FACBA0;
  --border-soft: #FDDCBF;
  --icon-1-bg: #FEF0E5; --icon-1-fg: #7A3308;
  --icon-2-bg: #FAD4AD; --icon-2-fg: #5A2202;
  --icon-3-bg: #F5AE75; --icon-3-fg: #3A1400;
  --icon-4-bg: #5A2202; --icon-4-fg: #FDDCBF;
}
[data-color="red"] {
  --accent: #E74C3C;
  --accent-hover: #C0392B;
  --accent-soft: #FDEDEC;
  --pink: #F9D5D3;
  --pink-soft: #FDEDEC;
  --pink-deep: #F1ABA6;
  --border: #F1ABA6;
  --border-soft: #F9D5D3;
  --icon-1-bg: #FDEDEC; --icon-1-fg: #7A1A12;
  --icon-2-bg: #F5B5B1; --icon-2-fg: #560F08;
  --icon-3-bg: #ED7E78; --icon-3-fg: #360603;
  --icon-4-bg: #560F08; --icon-4-fg: #FDEDEC;
}
[data-color="teal"] {
  --accent: #1ABC9C;
  --accent-hover: #16A085;
  --accent-soft: #E8FBF6;
  --pink: #D1F2EB;
  --pink-soft: #E8FBF6;
  --pink-deep: #A3E4D7;
  --border: #A3E4D7;
  --border-soft: #D1F2EB;
  --icon-1-bg: #E8FBF6; --icon-1-fg: #0A5E4A;
  --icon-2-bg: #A3E4D7; --icon-2-fg: #064030;
  --icon-3-bg: #5DCBB9; --icon-3-fg: #022416;
  --icon-4-bg: #064030; --icon-4-fg: #D1F2EB;
}
[data-color="gold"] {
  --accent: #F39C12;
  --accent-hover: #D4860E;
  --accent-soft: #FEF5E7;
  --pink: #FDE9CC;
  --pink-soft: #FEF5E7;
  --pink-deep: #FAD7A0;
  --border: #FAD7A0;
  --border-soft: #FDE9CC;
  --icon-1-bg: #FEF5E7; --icon-1-fg: #7A4A00;
  --icon-2-bg: #FAD7A0; --icon-2-fg: #5A3200;
  --icon-3-bg: #F5B347; --icon-3-fg: #3A1E00;
  --icon-4-bg: #5A3200; --icon-4-fg: #FDE9CC;
}

/* Dark mode + color combos
   RULE: in dark mode, only --accent, --accent-hover, --accent-soft change.
   --pink / --pink-soft / --pink-deep control the sidebar and body gradient,
   so they must stay as neutral dark tones — not match the accent hue,
   which would produce brown/orange/red sidebars.
   Border colours get a very slight accent tint for polish.              */
[data-theme="dark"][data-color="blue"]   {
  --accent: #8AB4F8; --accent-hover: #AECBFA; --accent-soft: rgba(138,180,248,0.15);
  --accent-2: #AECBFA; --accent-2-soft: rgba(174,203,250,0.12);
  --border: #3A4A5E; --border-soft: #2C3A4A;
  --btn-outline-border: #4A5E78; --btn-outline-text: #AECBFA;
}
[data-theme="dark"][data-color="green"]  {
  --accent: #81C784; --accent-hover: #A5D6A7; --accent-soft: rgba(129,199,132,0.15);
  --accent-2: #A5D6A7; --accent-2-soft: rgba(165,214,167,0.12);
  --border: #3A4E3C; --border-soft: #2C3C2E;
  --btn-outline-border: #4A624C; --btn-outline-text: #A5D6A7;
}
[data-theme="dark"][data-color="purple"] {
  --accent: #B39DDB; --accent-hover: #CE93D8; --accent-soft: rgba(179,157,219,0.15);
  --accent-2: #CE93D8; --accent-2-soft: rgba(206,147,216,0.12);
  --border: #4A3A5E; --border-soft: #382A4A;
  --btn-outline-border: #5E4A78; --btn-outline-text: #CE93D8;
}
[data-theme="dark"][data-color="orange"] {
  --accent: #FFB74D; --accent-hover: #FFCC80; --accent-soft: rgba(255,183,77,0.15);
  --accent-2: #FFCC80; --accent-2-soft: rgba(255,204,128,0.12);
  /* sidebar/body stays neutral dark — no orange background */
  --border: #4A3E2E; --border-soft: #3A2E22;
  --btn-outline-border: #5E4E3A; --btn-outline-text: #FFCC80;
}
[data-theme="dark"][data-color="red"]    {
  --accent: #EF9A9A; --accent-hover: #FFCDD2; --accent-soft: rgba(239,154,154,0.15);
  --accent-2: #FFCDD2; --accent-2-soft: rgba(255,205,210,0.12);
  --border: #4A2E2E; --border-soft: #3A2222;
  --btn-outline-border: #5E3A3A; --btn-outline-text: #FFCDD2;
}
[data-theme="dark"][data-color="teal"]   {
  --accent: #80CBC4; --accent-hover: #A7DFDB; --accent-soft: rgba(128,203,196,0.15);
  --accent-2: #A7DFDB; --accent-2-soft: rgba(167,223,219,0.12);
  --border: #2E4A48; --border-soft: #223A38;
  --btn-outline-border: #3A5E5C; --btn-outline-text: #A7DFDB;
}
[data-theme="dark"][data-color="gold"]   {
  --accent: #FFD54F; --accent-hover: #FFE082; --accent-soft: rgba(255,213,79,0.15);
  --accent-2: #FFE082; --accent-2-soft: rgba(255,224,130,0.12);
  /* sidebar/body stays neutral dark — no gold/amber background */
  --border: #4A422E; --border-soft: #3A3222;
  --btn-outline-border: #5E5238; --btn-outline-text: #FFE082;
}
[data-theme="dark"][data-color] {
  --pink:      #3D2A38;
  --pink-soft: #34242F;
  --pink-deep: #4A3242;
}

/* Icon chip palette overrides for dark + color combos.
   Each set gives the chips a tinted-glass look in the chosen accent hue
   while keeping foreground text readable (checked for ≥4.5:1 contrast).  */
[data-theme="dark"][data-color="blue"] {
  --icon-1-bg: rgba(138,180,248,0.18); --icon-1-fg: #AECBFA;
  --icon-2-bg: rgba(100,140,210,0.22); --icon-2-fg: #8AB4F8;
  --icon-3-bg: rgba(70,110,190,0.28);  --icon-3-fg: #D0DCFA;
  --icon-4-bg: rgba(10,42,110,0.6);    --icon-4-fg: #D0DCFA;
}
[data-theme="dark"][data-color="green"] {
  --icon-1-bg: rgba(129,199,132,0.18); --icon-1-fg: #A5D6A7;
  --icon-2-bg: rgba(90,160,95,0.22);   --icon-2-fg: #81C784;
  --icon-3-bg: rgba(50,120,60,0.28);   --icon-3-fg: #D0EFC4;
  --icon-4-bg: rgba(20,74,30,0.6);     --icon-4-fg: #D0EFC4;
}
[data-theme="dark"][data-color="purple"] {
  --icon-1-bg: rgba(179,157,219,0.18); --icon-1-fg: #CE93D8;
  --icon-2-bg: rgba(140,110,200,0.22); --icon-2-fg: #B39DDB;
  --icon-3-bg: rgba(100,70,160,0.28);  --icon-3-fg: #DDD6FE;
  --icon-4-bg: rgba(46,15,110,0.6);    --icon-4-fg: #DDD6FE;
}
[data-theme="dark"][data-color="orange"] {
  --icon-1-bg: rgba(255,183,77,0.18);  --icon-1-fg: #FFCC80;
  --icon-2-bg: rgba(220,140,40,0.22);  --icon-2-fg: #FFB74D;
  --icon-3-bg: rgba(180,100,10,0.28);  --icon-3-fg: #FDDCBF;
  --icon-4-bg: rgba(90,34,2,0.65);     --icon-4-fg: #FDDCBF;
}
[data-theme="dark"][data-color="red"] {
  --icon-1-bg: rgba(239,154,154,0.18); --icon-1-fg: #FFCDD2;
  --icon-2-bg: rgba(200,100,100,0.22); --icon-2-fg: #EF9A9A;
  --icon-3-bg: rgba(160,60,60,0.28);   --icon-3-fg: #FDEDEC;
  --icon-4-bg: rgba(86,15,8,0.65);     --icon-4-fg: #FDEDEC;
}
[data-theme="dark"][data-color="teal"] {
  --icon-1-bg: rgba(128,203,196,0.18); --icon-1-fg: #A7DFDB;
  --icon-2-bg: rgba(80,160,155,0.22);  --icon-2-fg: #80CBC4;
  --icon-3-bg: rgba(40,120,115,0.28);  --icon-3-fg: #D1F2EB;
  --icon-4-bg: rgba(6,64,48,0.65);     --icon-4-fg: #D1F2EB;
}
[data-theme="dark"][data-color="gold"] {
  --icon-1-bg: rgba(255,213,79,0.18);  --icon-1-fg: #FFE082;
  --icon-2-bg: rgba(220,165,20,0.22);  --icon-2-fg: #FFD54F;
  --icon-3-bg: rgba(180,120,0,0.28);   --icon-3-fg: #FDE9CC;
  --icon-4-bg: rgba(90,50,0,0.65);     --icon-4-fg: #FDE9CC;
}
/* ============================================================
   Theme Toggle & Color Picker Button Styles (pill/circle look)
   ============================================================ */
.theme-toggle-btn,
.color-picker-wrap .icon-btn {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 0;
  font-size: 1rem;
}
.theme-toggle-btn:hover,
.color-picker-wrap .icon-btn:hover {
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
[data-theme="dark"] .theme-toggle-btn,
[data-theme="dark"] .color-picker-wrap .icon-btn {
  background: var(--paper-raised);
  border-color: var(--border);
}


/* ============================================================
   RESPONSIVE / MOBILE — comprehensive overrides
   Breakpoints used:
     860px  — sidebar goes off-canvas (hamburger toggle)
     640px  — content padding shrinks, panels/forms tighten
     480px  — phones: single-column everything, full-width forms
   ============================================================ */

/* ── Hamburger button (hidden on desktop) ──────────────────── */
.hamburger-btn {
  display: none;               /* shown only at ≤860px */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  /* give it enough touch target size */
  min-width: 44px;
  min-height: 44px;
}
.hamburger-btn:hover { background: var(--accent-soft); }
.hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: background 0.15s;
}
[data-theme="dark"] .hamburger-bar { background: var(--ink); }

/* ── Sidebar backdrop (overlay behind the open drawer) ─────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 149;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop--visible { display: block; }

/* ── 860px — sidebar becomes an off-canvas drawer ─────────── */
@media (max-width: 860px) {

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* App shell: stack topbar / content only (sidebar floats over) */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .app-shell .topbar {
    grid-column: 1;
    grid-row: 1;
    padding: 12px 16px;
    flex-wrap: nowrap;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--pink);
    border-bottom: 1px solid var(--border);
  }
  .app-shell .content,
  .app-shell main.content {
    grid-column: 1;
    grid-row: 2;
    padding: 16px 16px 32px;
  }

  /* Sidebar: fixed off-canvas drawer, slides in from the left */
  .app-shell .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100%;
    z-index: 150;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-raised);
  }
  .app-shell .sidebar.sidebar--open {
    transform: translateX(0);
  }

  /* Topbar title — hide on small screens to save space */
  .topbar-title { display: none; }

  /* Reduce topbar right icon gaps on tablet */
  .topbar-right { gap: 6px; }

  /* User menu name text — hide on narrower screens */
  .user-menu-name { display: none; }

  /* Notification / message dropdowns — adjust width and position */
  .notif-dropdown,
  .msg-dropdown {
    width: min(300px, 90vw);
    right: -8px;
  }

  /* Page header stacks on tablet */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Grid layout tightens */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }

  /* All data tables get a horizontal scroll wrapper via panel-table-wrap */
  .panel-table-wrap { overflow-x: auto; }

  /* Form grid: 2 columns → 1 */
  .form-grid { grid-template-columns: 1fr !important; }

  /* .form-group full spans are already 1-col so no change needed */

  /* Prevent body scroll when sidebar drawer is open */
  body.sidebar-is-open { overflow: hidden; }
}

/* ── 640px — phones/small tablets ─────────────────────────── */
@media (max-width: 640px) {

  /* Content area: reduce padding */
  .app-shell .content,
  .app-shell main.content {
    padding: 12px 12px 24px;
  }

  /* Panels: tighter padding */
  .panel { padding: 14px 14px; }

  /* Stat tiles: compact */
  .stat-tile { padding: 14px 14px 12px; }
  .stat-value { font-size: 24px; }

  /* Quick-actions: 2 columns */
  .quick-actions { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Page header: full-width action buttons */
  .page-header .header-actions,
  .page-header > div:last-child {
    width: 100%;
  }
  .page-header .btn,
  .page-header > div:last-child .btn {
    width: 100%;
    justify-content: center;
  }

  /* Tables: ensure horizontal scroll, no overflow clip */
  .table-compact { font-size: 12.5px; }
  .table-compact thead th { font-size: 10px; padding: 0 7px 8px; }
  .table-compact tbody td { padding: 9px 7px; }

  /* Table action buttons: bigger touch targets */
  .table-actions a,
  .table-actions button,
  .table-actions .btn { min-height: 36px; }

  /* Three-dot action menu button: always 44×44 touch target */
  .drive-kebab-btn,
  .row-menu-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.3rem;
  }

  /* Dropdown menus: ensure they don't overflow viewport */
  .user-menu-dropdown {
    right: 0;
    width: min(240px, 90vw);
  }

  /* app-content wrapper */
  .app-content { padding: 12px 12px 32px; }
}

/* ── 480px — small phones ──────────────────────────────────── */
@media (max-width: 480px) {

  /* Single column everything */
  .quick-actions { grid-template-columns: 1fr; }
  .grid-4,
  .grid-3,
  .grid-2 { grid-template-columns: 1fr; }

  /* Remove horizontal padding on outermost wrapper */
  .app-shell .content,
  .app-shell main.content {
    padding: 10px 10px 20px;
  }

  /* Panels flush to edge */
  .panel { padding: 12px 12px; border-radius: var(--radius-sm); }

  /* Form actions: full-width stacked buttons */
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Login card: full-width on tiny phones */
  .login-card,
  .login-form-inner {
    max-width: 100%;
  }
  .login-card-body { padding: 20px 16px 18px; }

  /* Remove topbar-spacer flex gap on tiny screens */
  .topbar-spacer { flex: 0; }

  /* Topbar: tighter */
  .app-shell .topbar { padding: 10px 12px; }
  .topbar-right { gap: 4px; }

  /* Notification + message dropdowns: full-width sheet from top */
  .notif-dropdown,
  .msg-dropdown {
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 70vh;
  }

  /* Drive share modal: bottom sheet */
  .drive-share-overlay,
  .gdocs-share-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .drive-share-box,
  .gshare-box {
    max-width: 100% !important;
    max-height: 85vh !important;
    border-radius: 16px 16px 0 0 !important;
    width: 100% !important;
  }

  /* Preview overlay: always full screen on phones */
  .gdocs-preview-shell {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }

  /* Table: hide lower-priority columns on tiny phones */
  /* (page-specific hiding is handled per-page; this is the global fallback) */
  .table-compact thead th:nth-child(n+4),
  .table-compact tbody td:nth-child(n+4) {
    display: none;
  }

  /* Stat tiles: reduce font sizes */
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
}

/* ── Ensure all tables are scrollable horizontally ─────────── */
/* Applied regardless of breakpoint so large tables never overflow */
.panel > table,
.panel > .table-responsive > table {
  min-width: 500px;  /* prevents columns from being squished to unusable widths */
}

/* Wrap all bare panel > table in a scroll container */
/* (This is a CSS-only fallback; ideally wrap in PHP, but this prevents clipping) */
.panel {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Ensure touch targets are 44px minimum everywhere ──────── */
.btn-sm {
  min-height: 36px;   /* slightly relaxed for inline usage */
  min-width: 36px;
}
nav a,
.sidebar nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ── Fix: topbar z-index so it sits above all content ──────── */
.app-shell .topbar {
  position: sticky;
  top: 0;
  z-index: 90;
}

/* ── Prevent horizontal overflow on the whole page ─────────── */
html, body {
  overflow-x: hidden;
}
/* ===== Excel viewer (shared by Dashboard + Documents) ===== */
.drive-preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.drive-preview-overlay.open { display: flex; }
.drive-preview-box {
  background: var(--paper-card);
  border-radius: 10px;
  width: 90%;
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drive-preview-box.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  border-radius: 0;
}
.drive-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  color: var(--ink);
}
.drive-preview-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.drive-preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  position: relative;
}
.drive-preview-body iframe,
.drive-preview-body img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
}
.drive-preview-body .drive-preview-unsupported {
  padding: 40px;
  text-align: center;
  color: var(--ink-soft);
}

#xlsxFidelityRoot td[contenteditable="true"]:focus { outline: 2px solid #1a73e8; outline-offset: -2px; }
.drive-preview-body, #xlsxScroll { overscroll-behavior: contain; }
body:has(.drive-preview-overlay.open) { overflow: hidden; }
#xlsxScroll { contain: layout paint; }
#xlsxFidelityRoot td.xsel { box-shadow: inset 0 0 0 1000px rgba(26,115,232,0.16); }
#xlsxFidelityRoot td.xact { outline: 2px solid #1a73e8; outline-offset: -2px; }
#xlsxToolbar .xrow { display: flex; align-items: center; gap: 6px; padding: 5px 10px; flex-wrap: wrap; }
#xlsxToolbar .xtools { background: #edf2fa; border-radius: 24px; margin: 2px 8px; padding: 3px 8px; }
#xlsxToolbar .xtb { border: none; background: transparent; padding: 4px 8px; border-radius: 4px; cursor: pointer; font: 14px Arial, sans-serif; color: #222; min-width: 28px; }
#xlsxToolbar .xtb:hover { background: #dde3ea; }
#xlsxToolbar .xtb.on { background: #d3e3fd; }
#xlsxToolbar .xsep { width: 1px; height: 20px; background: #c4c7c5; margin: 0 4px; }
#xlsxToolbar .xlbl { font-weight: bold; color: #444; }
#xlsxToolbar input[type="color"] { width: 26px; height: 24px; padding: 0; border: 1px solid #ccc; background: none; cursor: pointer; }
#xlsxToolbar select, #xlsxToolbar input[type="number"], #xlsxToolbar input[readonly], #xlsxToolbar #xlsxFx { font: 13px Arial, sans-serif; padding: 3px 5px; border: 1px solid #ccc; border-radius: 4px; background: #fff; color: #222; }

.drive-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 30, 30, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
  z-index: 1100;
  max-width: 90vw;
  text-align: center;
}
.drive-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================
   ARCHIVES ACTION BUTTONS — THEME-AWARE COLORS
   Preview and Restore follow the selected accent color.
   Destructive actions remain red for safety.
   ========================================================== */

/* Preview and Restore buttons */
.btn-outline {
    background: var(--accent-soft) !important;
    color: var(--accent-2) !important;
    border: 1px solid var(--accent) !important;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-outline:hover,
.btn-outline:focus-visible {
    background: var(--accent) !important;
    border-color: var(--accent-hover) !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 0 2px var(--accent-soft);
}

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

/* Small action buttons */
.btn-outline.btn-sm {
    font-weight: 700;
}

/* Destructive actions: stay red regardless of selected theme */
.btn-danger {
    background: #A52F38 !important;
    border: 1px solid #8E222B !important;
    color: #FFFFFF !important;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-danger:hover,
.btn-danger:focus-visible {
    background: #7F1D25 !important;
    border-color: #6B1720 !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 0 2px rgba(165, 47, 56, 0.22);
}

.btn-danger:focus-visible {
    outline: 2px solid #A52F38;
    outline-offset: 2px;
}

/* Disabled buttons */
.btn-outline:disabled,
.btn-danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* =====================================================
   MEMBERS TABLE — ALIGN HEADERS AND ROW DATA
   ===================================================== */

.members-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

/* Consistent header alignment */
.members-table thead th {
    text-align: left;
    vertical-align: middle;
    padding: 12px 10px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

/* Matching body-cell alignment */
.members-table tbody td {
    text-align: left;
    vertical-align: middle;
    padding: 12px 10px;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    border-bottom: 1px solid var(--border-soft);
}

/* Column widths — total 100% */
.members-table th:nth-child(1),
.members-table td:nth-child(1) {
    width: 11%;
}

.members-table th:nth-child(2),
.members-table td:nth-child(2) {
    width: 20%;
}

.members-table th:nth-child(3),
.members-table td:nth-child(3) {
    width: 13%;
}

.members-table th:nth-child(4),
.members-table td:nth-child(4) {
    width: 23%;
}

.members-table th:nth-child(5),
.members-table td:nth-child(5) {
    width: 15%;
}

.members-table th:nth-child(6),
.members-table td:nth-child(6) {
    width: 9%;
}

.members-table th:nth-child(7),
.members-table td:nth-child(7) {
    width: 9%;
}

/* Email values should not stretch the table */
.members-table td:nth-child(4) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Keep action buttons aligned in their column */
.members-table td:nth-child(7) {
    white-space: normal;
}

.members-table td:nth-child(7) .btn,
.members-table td:nth-child(7) button {
    margin: 2px 3px 2px 0;
    vertical-align: middle;
}

/* Responsive layout for smaller screens */
@media (max-width: 900px) {
    .members-table {
        min-width: 850px;
    }

    .members-table-wrapper {
        overflow-x: auto;
        width: 100%;
    }
}
