@import "dept-google-sheets.css";
@import "section-preview.css";
@import "section-launch.css";
@import "dept-tabs.css";
@import "home.css";

/* ─── Variables ──────────────────────────────────────────────────────── */
:root {
  --bg:           #FAF8F5;
  --surface:      #FFFFFF;
  --sidebar:      #1A1A1A;
  --orange:       #E8521A;
  --orange-h:     #CF4917;
  --orange-light: rgba(232,82,26,.1);
  --text:         #1A1A1A;
  --muted:        #6B7280;
  --border:       #E5E3DF;
  --border-dark:  rgba(255,255,255,.08);
  --radius:       10px;
  --topbar-h:     52px;
  --sidebar-w:    220px;
  --sidebar-w-collapsed: 60px;
  --sh-sm:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:        0 4px 16px rgba(0,0,0,.08);
  --font-h:       'Inter', sans-serif;
  --font-b:       'Inter', sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-b); background: var(--bg); color: var(--text);
       font-size: 14px; line-height: 1.5;
       font-stretch: normal; font-variation-settings: normal;
       -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button { font-family: var(--font-b); font-stretch: normal; font-variation-settings: normal; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-b); font-size: 14px; font-stretch: normal; font-variation-settings: normal; }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ─── Login — split-screen ───────────────────────────────────────────── */
#login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Left hero ────────────────────────────────────────────────────────── */
.login-hero {
  position: relative;
  background: linear-gradient(145deg, #C63E0C 0%, #E8521A 45%, #F97316 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 52px;
  overflow: hidden;
}

/* Animated glow orbs */
.lh-orbs { position: absolute; inset: 0; pointer-events: none; }

.lh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
}

.lh-orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(255,255,255,.28) 0%, transparent 70%);
  top: -260px; left: -260px;
  animation: lh-float 22s ease-in-out infinite;
}
.lh-orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0%, transparent 70%);
  bottom: -200px; right: -180px;
  animation: lh-float 18s ease-in-out infinite reverse;
  animation-delay: -8s;
}
.lh-orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,200,150,.22) 0%, transparent 70%);
  top: 55%; left: 40%;
  animation: lh-float 26s ease-in-out infinite;
  animation-delay: -14s;
}

@keyframes lh-float {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(28px,-28px) scale(1.08); }
  66%      { transform: translate(-18px,22px) scale(.93); }
}

/* Floating particles */
.lh-particle {
  position: absolute;
  background: rgba(255,255,255,.55);
  border-radius: 50%;
  pointer-events: none;
  animation: lh-particle-rise linear infinite;
}

@keyframes lh-particle-rise {
  0%   { transform: translateY(0)  scale(1);   opacity: 0; }
  10%  { opacity: .6; }
  90%  { opacity: .4; }
  100% { transform: translateY(-110vh) scale(.4); opacity: 0; }
}

/* Hero content */
.lh-content {
  position: relative;
  z-index: 10;
  text-align: center;
  color: #fff;
  animation: lh-fade-up .9s ease-out both;
}

.lh-logo {
  height: 64px;
  width: auto;
  margin: 0 auto 28px;
  filter: brightness(0) invert(1);
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.18)) brightness(0) invert(1);
  animation: lh-fade-up .8s ease-out both;
}

.lh-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 14px;
  text-shadow: 0 3px 12px rgba(0,0,0,.18);
  animation: lh-fade-up .8s ease-out .15s both;
}

.lh-sub {
  font-size: 18px;
  font-weight: 400;
  opacity: .9;
  margin-bottom: 52px;
  animation: lh-fade-up .8s ease-out .3s both;
}

/* Checklist */
.lh-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: lh-fade-up .8s ease-out .45s both;
}

.lh-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  opacity: .92;
}

.lh-checklist li::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

@keyframes lh-fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Right form side ──────────────────────────────────────────────────── */
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  background: #FAFAFA;
}

.login-form-wrap {
  width: 100%;
  max-width: 400px;
  animation: lh-fade-up 1s ease-out .1s both;
}

.login-form-head {
  margin-bottom: 36px;
}
.login-form-head h2 {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.login-form-head p {
  font-size: 15px;
  color: var(--muted);
}

/* Google button — white card style */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 15px 24px;
  background: #fff;
  color: #1F2937;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-b);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.btn-google:hover {
  border-color: var(--orange);
  box-shadow: 0 8px 24px rgba(232,82,26,.14);
  transform: translateY(-2px);
}
.btn-google:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.login-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.login-note {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.login-error {
  color: #c0392b;
  min-height: 18px;
  margin-top: 12px;
  font-size: 13px;
  text-align: center;
}

/* Pending state */
.login-pending { display: none; }
.login-pending.visible { display: block; }
.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.btn-text {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  padding: 8px;
  border-radius: 6px;
  transition: color .12s;
}
.btn-text:hover { color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  #login-page { grid-template-columns: 1fr; }
  .login-hero  { display: none; }
  .login-form-side { padding: 48px 28px; background: var(--bg); }
}

/* ─── App Shell ──────────────────────────────────────────────────────── */
#app {
  display: none; /* shown by JS when auth confirmed */
  flex-direction: column;
  height: 100vh;
}
#app.ready { display: flex; }

/* ─── Top Bar ────────────────────────────────────────────────────────── */
#top-bar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 40;
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.top-bar-brand .app-name {
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.top-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

#top-bar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
}
.bc-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-sep  { color: var(--border); flex-shrink: 0; }
.bc-item.current { color: var(--text); font-weight: 500; }
.bc-link {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--muted); font-family: var(--font-b); padding: 0;
  transition: color .1s;
}
.bc-link:hover { color: var(--text); }

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#top-bar-user { font-size: 13px; color: var(--muted); }
.btn-signout {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: border-color .12s, color .12s;
}
.btn-signout:hover { border-color: var(--muted); color: var(--text); }

/* ─── Body Row ───────────────────────────────────────────────────────── */
#body-row { display: flex; flex: 1; overflow: hidden; }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 0;
  transition: width .25s ease;
}

/* Collapse toggle button — sits at the top of the sidebar */
.sidebar-toggle-btn {
  margin: 0 12px 8px;
  padding: 6px 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;          /* hugs the right edge of the sidebar */
  transition: background .12s, color .12s;
}
.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,.10);
  color: #ccc;
}
.sidebar-toggle-btn svg { transition: transform .25s ease; }

/* Collapsed-state rules — desktop only. Mobile (≤720px) uses the
   existing fixed/translateX overlay pattern; collapsing to 60px would
   make that overlay unusable. */
@media (min-width: 721px) {
  #sidebar.collapsed { width: var(--sidebar-w-collapsed); }
  #sidebar.collapsed .sidebar-toggle-btn {
    align-self: center;
    margin: 0 0 8px;
  }
  #sidebar.collapsed .sidebar-toggle-btn svg { transform: rotate(180deg); }

  /* Hide all text content; keep icons and section dividers */
  #sidebar.collapsed .s-name,
  #sidebar.collapsed .sidebar-chevron,
  #sidebar.collapsed .sidebar-sub-list,
  #sidebar.collapsed .sidebar-empty,
  #sidebar.collapsed .sidebar-label { display: none; }
  #sidebar.collapsed .sidebar-divider { margin: 6px 12px; }

  /* Center the icon within the narrow strip */
  #sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
  }
  #sidebar.collapsed .s-icon { font-size: 17px; }
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #555;
  padding: 14px 16px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: background .1s, color .1s;
  cursor: pointer;
}
.sidebar-item:hover  { background: rgba(255,255,255,.05); color: #ccc; }
.sidebar-item.active { background: rgba(232,82,26,.15); color: #fff; border-left-color: var(--orange); }
.sidebar-item .s-icon { font-size: 15px; flex-shrink: 0; line-height: 1; }
.sidebar-item .s-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-add-dept { color: var(--orange) !important; opacity: .85; }
.sidebar-add-dept:hover { opacity: 1; background: rgba(232,82,26,.12) !important; }

/* Collapsible dept group */
.sidebar-dept-group  { }
.sidebar-dept-row    { cursor: pointer; }

.sidebar-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 4px;
  color: #555;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: color .1s, transform .2s;
}
.sidebar-chevron:hover { color: #aaa; }
.sidebar-chevron.open  { transform: rotate(0deg); }
.sidebar-chevron:not(.open) { transform: rotate(-90deg); }

/* Sub-list (sections) */
.sidebar-sub-list {
  overflow: hidden;
  max-height: 0;
  transition: max-height .22s ease;
}
.sidebar-sub-list.open { max-height: 600px; }

.sidebar-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 38px;
  font-size: 12.5px;
  font-weight: 500;
  color: #777;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .1s, color .1s;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
}
.sidebar-sub-item:hover  { background: rgba(255,255,255,.04); color: #ccc; }
.sidebar-sub-item.active { background: rgba(232,82,26,.12); color: #fff; border-left-color: var(--orange); }

.s-sub-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: .5;
}

.sidebar-sub-empty {
  padding: 5px 16px 8px 38px;
  font-size: 11px;
  color: #444;
  font-style: italic;
}

.sidebar-empty {
  padding: 12px 16px;
  font-size: 12px;
  color: #444;
}

.sidebar-spacer { flex: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.06); margin: 8px 0; }

/* ─── Content ────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  min-width: 0;        /* flex items default to min-width:auto, which lets a
                          wide descendant push the whole layout past the
                          viewport — this lets #content shrink as needed. */
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#content.full-bleed-page { overflow: hidden; }
#content.full-bleed-page > .stats-iframe { flex: 1; min-height: 0; }

/* ─── Page Wrapper ───────────────────────────────────────────────────── */
.page-wrap { padding: 32px 36px; max-width: 1100px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-head h1 {
  font-family: var(--font-h);
  font-size: 24px;
  font-weight: 700;
}
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Back button */
.page-back { margin-bottom: 8px; }
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-b);
  transition: color .1s, background .1s;
}
.btn-back:hover { color: var(--text); background: var(--border); }

/* ─── Home page ──────────────────────────────────────────────────────── */
.home-welcome {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}
.home-welcome-text h1 {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}
.home-welcome-text p { font-size: 14px; color: var(--muted); }

.home-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Overview strip */
.overview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overview-card:hover { box-shadow: var(--sh-md); border-color: #ccc; }

.overview-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ov-icon { font-size: 18px; line-height: 1; }
.ov-name { font-family: var(--font-h); font-size: 14px; font-weight: 700; }

.ov-placeholder {
  flex: 1;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.ov-footer {
  display: flex;
  justify-content: flex-end;
}

.overview-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 20px 0;
}

/* ─── Dept Cards (Home) ──────────────────────────────────────────────── */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.dept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.dept-card:hover {
  box-shadow: var(--sh-md);
  border-color: #ccc;
  transform: translateY(-1px);
}
.dept-card-icon { font-size: 32px; line-height: 1; }
.dept-card-name {
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
}
.dept-card-meta { font-size: 12px; color: var(--muted); }

/* Add new dept card */
.dept-card-add {
  border-style: dashed;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.dept-card-add:hover { color: var(--orange); border-color: var(--orange); }
.dept-card-add .add-icon { font-size: 22px; }

/* ─── Admin Table ────────────────────────────────────────────────────── */
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table-wrap th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.admin-table-wrap td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.admin-table-wrap tr:last-child td { border-bottom: none; }
.admin-table-wrap tr:hover td { background: var(--bg); }

.td-icon  { font-size: 20px; line-height: 1; }
.td-muted { font-size: 12px; color: var(--muted); }

.row-actions { display: flex; gap: 6px; }

.btn-sm {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color .1s;
}
.btn-sm:hover  { border-color: var(--muted); }
.btn-sm.danger { color: #c0392b; border-color: #ffd5c8; background: #fff0ed; }
.btn-sm.danger:hover { background: #ffe0d9; }

/* Empty table state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Dashboard blank/empty state */
.dashboard-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 60vh;
  color: var(--muted);
  text-align: center;
  gap: 12px;
}
.dashboard-empty-icon { font-size: 48px; opacity: .5; }
.dashboard-empty-state h2 { font-size: 18px; font-weight: 600; color: var(--text); opacity: .45; }
.dashboard-empty-state p  { font-size: 14px; max-width: 280px; line-height: 1.6; }

/* ─── Dashboard page ─────────────────────────────────────────────────── */
.dashboard-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Horizontal nav bar */
.dash-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.dash-nav::-webkit-scrollbar { display: none; }

.dash-nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
  margin-bottom: -1px;
}
.dash-nav-tab:hover  { color: var(--text); }
.dash-nav-tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.dash-nav-icon       { font-size: 15px; }

/* Content area below nav */
.dash-content {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* Overview grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px;
}
.overview-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .1s;
}
.overview-card:hover {
  border-color: var(--orange);
  box-shadow: 0 2px 12px rgba(232,82,26,.1);
  transform: translateY(-1px);
}
.ov-icon  { font-size: 28px; flex-shrink: 0; line-height: 1; }
.ov-body  { flex: 1; min-width: 0; }
.ov-body h3    { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.ov-count      { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ov-none       { font-style: italic; }
.ov-tabs       { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.ov-tabs li    { font-size: 11px; padding: 2px 8px; background: var(--bg); border: 1px solid var(--border);
                 border-radius: 20px; color: var(--muted); }
.ov-arrow      { color: var(--muted); font-size: 16px; flex-shrink: 0; align-self: center; opacity: .4; }

/* Dept dashboard view */
.dept-dash {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.dept-sub-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.dept-sub-tabs::-webkit-scrollbar { display: none; }
.dept-sub-tab {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
.dept-sub-tab:hover  { color: var(--text); border-color: #aaa; }
.dept-sub-tab.active { color: var(--orange); border-color: var(--orange); background: var(--orange-light); }

.dept-iframe-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}
.dept-dash-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--orange);
  color: #fff;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-b);
  border: none;
  cursor: pointer;
  transition: background .12s;
}
.btn-primary:hover { background: var(--orange-h); }
.btn-primary svg, .btn-primary .btn-icon { flex-shrink: 0; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-b);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .12s;
}
.btn-secondary:hover { border-color: var(--muted); }

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: 14px;
  width: 460px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
}
.btn-modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 18px;
  transition: background .1s;
}
.btn-modal-close:hover { background: var(--bg); }

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

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-b);
  outline: none;
  transition: border-color .12s;
}
.form-input:focus { border-color: var(--orange); }

/* Icon picker */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.icon-opt {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border-radius: 7px;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  transition: background .12s, border-color .12s, transform .1s;
  user-select: none;
}
.icon-opt:hover {
  background: #ede9e4;
  border-color: #b0ada8;
  transform: scale(1.12);
}
.icon-opt.selected {
  border-color: var(--orange);
  background: var(--orange-light);
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(232,82,26,.18);
}

/* ─── Confirm ────────────────────────────────────────────────────────── */
#confirm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#confirm-overlay.open { display: flex; }

#confirm-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  text-align: center;
}
#confirm-box h4 {
  font-family: var(--font-h);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}
#confirm-box p { font-size: 13px; color: var(--muted); margin-bottom: 24px; line-height: 1.55; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.btn-confirm-cancel { padding: 9px 20px; border-radius: 7px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-family: var(--font-b); }
.btn-confirm-ok    { padding: 9px 20px; border-radius: 7px; font-size: 13px; font-weight: 600; background: #c0392b; color: #fff; cursor: pointer; font-family: var(--font-b); }
.btn-confirm-ok:hover { background: #a93226; }

/* ─── Toast ──────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  animation: slide-up .2s ease;
  max-width: 320px;
}
.toast-success { background: #1a7a4a; }
.toast-error   { background: #c0392b; }
.toast-info    { background: #1a56c4; }
@keyframes slide-up {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ─── Loading / States ───────────────────────────────────────────────── */
.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.coming-soon-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 60vh; text-align: center;
}
.coming-soon-page h2 {
  font-family: var(--font-h);
  font-size: 26px; font-weight: 700; margin-bottom: 10px;
}
.coming-soon-page p { font-size: 15px; color: var(--muted); }

/* ─── Dashboard Page ─────────────────────────────────────────────────── */
.dash-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-tabs-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow-x: auto;
}

.dash-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 7px 7px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, background .12s;
  margin-bottom: -1px;
}
.dash-tab:hover { color: var(--text); background: var(--bg); }
.dash-tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  font-weight: 600;
}

.dash-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 50vh;
  text-align: center;
  color: var(--muted);
}
.dash-empty h2 {
  font-family: var(--font-h);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.dash-empty p { font-size: 14px; line-height: 1.6; }

/* ─── Dashboard Section Block ────────────────────────────────────────── */
.dash-section-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dash-section-head h3 {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
}

.dash-chart-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* ─── KPI Cards ──────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-family: var(--font-h);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--muted);
}

/* ─── Department Page — Section Cards ───────────────────────────────── */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  display: flex;
  flex-direction: column;
}
.section-card:hover {
  box-shadow: var(--sh-md);
  border-color: #ccc;
  transform: translateY(-1px);
}
.section-card:focus {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.section-card-main {
  padding: 20px 18px 16px;
  flex: 1;
}

.section-card-name {
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.section-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.section-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ─── Toggle Switch ──────────────────────────────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
  background: #ccc;
  border-radius: 19px;
  flex-shrink: 0;
  transition: background .18s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-input:checked + .toggle-slider {
  background: var(--orange);
}
.toggle-input:checked + .toggle-slider::after {
  transform: translateX(15px);
}

.toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/* ─── Section Page ───────────────────────────────────────────────────── */
.section-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* KPI row for section page */
.section-kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.section-kpi-row .kpi-card {
  min-width: 140px;
  flex: 1;
}

/* Table card */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.table-card-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
}

.table-scroll {
  overflow-x: auto;
}

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

table.spreadsheet th {
  text-align: left;
  padding: 9px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

table.spreadsheet td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.spreadsheet tr:last-child td { border-bottom: none; }
table.spreadsheet tr:hover td { background: #fafaf8; }

/* Cell */
.cell {
  padding: 9px 12px;
  min-width: 100px;
  min-height: 38px;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  color: var(--text);
}
.cell:empty::after {
  content: '—';
  color: var(--border);
}

.editable-cell {
  position: relative;
  cursor: text;
}
.editable-cell:hover { background: rgba(232,82,26,.04); }

.cell.editing {
  padding: 0;
  background: transparent;
}

.cell-input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  outline: 2px solid var(--orange);
  outline-offset: -2px;
  background: #fff;
  font-size: 13px;
  font-family: var(--font-b);
  color: var(--text);
  border-radius: 0;
  min-width: 100px;
}
.cell-input:focus { outline-color: var(--orange); }

/* Notes cell */
.notes-cell .cell {
  max-width: 300px;
  color: var(--muted);
  font-style: italic;
}

/* Edited indicator */
.edited-cell {
  position: relative;
}

/* Last edited info below table */
.last-edited-info {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
}
.edited-time { font-weight: 500; }

/* Column type badge in th */
.col-type-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  background: rgba(0,0,0,.06);
  color: var(--muted);
  vertical-align: middle;
  margin-left: 4px;
  text-transform: lowercase;
}

/* Delete column/row buttons */
.col-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 3px;
  color: #bbb;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border: none;
  background: none;
  margin-left: 4px;
  vertical-align: middle;
  transition: color .1s, background .1s;
}
.col-delete-btn:hover { color: #c0392b; background: #ffe0d9; }

.row-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  color: #bbb;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  transition: color .1s, background .1s;
  flex-shrink: 0;
}
.row-delete-btn:hover { color: #c0392b; background: #ffe0d9; }

/* Row number / actions column */
.td-row-num {
  width: 42px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}
.td-row-num .cell { min-width: unset; padding: 9px 6px; text-align: center; }

.td-actions {
  width: 36px;
  text-align: center;
  padding: 0 6px;
  border-left: 1px solid var(--border);
}
.td-actions .cell { padding: 9px 4px; min-width: unset; display: flex; align-items: center; justify-content: center; }

/* Add row bar */
.add-row-bar {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

/* Column manager in section */
.col-manager-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.col-manager-head h4 {
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
}

.col-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.col-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}
.col-item-label { flex: 1; font-weight: 500; }
.col-item-type  { font-size: 11px; color: var(--muted); }

/* Add column form inside modal */
.col-form-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.col-form-row .form-group { flex: 1; margin-bottom: 0; }
.col-form-row .form-group:last-of-type { flex: 0 0 140px; }

.form-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-b);
  outline: none;
  transition: border-color .12s;
  width: 100%;
  appearance: none;
}
.form-select:focus { border-color: var(--orange); }

/* ─── ⋮ Dot Menu (shared) ────────────────────────────────────────────── */
.dot-menu {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.dot-menu-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  letter-spacing: -.05em;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .1s, color .1s;
}
.dot-menu-btn:hover { background: var(--border); color: var(--text); }

.dot-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  z-index: 120;
  min-width: 170px;
  overflow: hidden;
  flex-direction: column;
  padding: 4px;
}
.dot-menu-dropdown.open { display: flex; }

.dot-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-b);
  border-radius: 6px;
  transition: background .1s;
  white-space: nowrap;
}
.dot-menu-item:hover         { background: var(--bg); }
.dot-menu-item.danger        { color: #c0392b; }
.dot-menu-item.danger:hover  { background: #fff0ed; }
.dot-menu-item svg           { flex-shrink: 0; opacity: .7; }

/* Thin rule between groups of menu items */
.dot-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ─── Move Section modal ─────────────────────────────────────────────── */
.move-sec-context {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 13px;
  margin-bottom: 14px;
}
.move-sec-context strong { color: var(--text); }

.move-dept-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.move-dept-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.move-dept-opt:hover    { border-color: #aaa; background: var(--bg); }
.move-dept-opt.selected {
  border-color: var(--orange);
  background: var(--orange-light);
  color: var(--text);
}

.move-dept-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.move-dept-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Department page title row ──────────────────────────────────────── */
.dept-page-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
/* Push the ⋮ button to align with the h1 baseline */
.dept-page-title > .dot-menu {
  margin-top: 6px;
}

/* ─── Department card menu (home page) ───────────────────────────────── */
.dept-card {
  position: relative;   /* needed so absolute dot-menu-dropdown is scoped */
}

.dept-card-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}
/* Dropdown opens downward from the card corner */
.dept-card-menu .dot-menu-dropdown {
  right: 0;
  top: calc(100% + 2px);
}

/* ─── Section card footer — flex row ─────────────────────────────────── */
.section-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* Section card icon */
.section-card-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 6px;
}

/* ─── Section Page — layout helpers ─────────────────────────────────── */
.section-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* CSV error banner */
.csv-error-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  font-size: 13px;
  color: #856404;
  margin-bottom: 20px;
}

/* Chart card */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Section Data divider */
.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 20px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Google Sheet iframe */
.sheet-embed-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  line-height: 0;   /* removes gap under iframe */
}

.sheet-embed {
  width: 100%;
  height: 600px;
  display: block;
  border: none;
}

.sheet-embed-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Allow btn-secondary styles on <a> tags */
a.btn-secondary {
  text-decoration: none;
}

/* Placeholder when no sheet is linked */
.sheet-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.sheet-placeholder p { font-size: 14px; line-height: 1.6; }

/* ─── Section Settings Modal ─────────────────────────────────────────── */
.settings-modal-box {
  width: 580px;
  max-width: calc(100vw - 32px);
}

.settings-modal-body {
  max-height: 72vh;
  overflow-y: auto;
}

/* Section rule inside modal */
.settings-rule {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 0 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Form hint text */
.form-hint {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}
.form-hint em { font-style: normal; color: var(--text); }

/* Form label sub-text */
.form-label-sub {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

/* KPI column header row in settings */
.settings-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

/* KPI column editor rows */
.kpi-col-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.kpi-col-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.kpi-col-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 80px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.kpi-col-row .form-input {
  padding: 6px 10px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}

/* Dashboard: empty KPI placeholder */
.kpi-card-empty {
  grid-column: 1 / -1;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* ─── Section page (Luckysheet layout) ──────────────────────────────── */
#content.section-page-active {
  overflow: hidden;
  padding: 0;
  /* height is already set by flex:1 in #body-row — we just remove padding */
}

.section-page {
  display: block;
  height: 100%;
}

.section-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.section-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.section-header-title {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.read-only-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.luckysheet-container {
  width: 100%;
  height: calc(100vh - 120px);
  min-height: 600px;
  position: relative;
  display: block;
}

/* ─── Custom Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--orange) 0%, #c94415 100%);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--orange); }
::-webkit-scrollbar-corner { background: transparent; }

/* ─── Page Fade Transition ───────────────────────────────────────────── */
@keyframes content-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#content.page-entering {
  animation: content-fade-in .18s ease forwards;
}

/* ─── Skeleton Loading ───────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
.skeleton-page {
  padding: 28px 28px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.skeleton-heading {
  height: 22px;
  width: 220px;
}
.skeleton-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.skeleton-kpi-card {
  height: 96px;
  border-radius: 10px;
}
.skeleton-section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.skeleton-card {
  height: 180px;
  border-radius: 10px;
}
@media (max-width: 720px) {
  .skeleton-kpi-row { grid-template-columns: 1fr 1fr; }
  .skeleton-section-row { grid-template-columns: 1fr; }
}

/* ─── Mobile Sidebar ─────────────────────────────────────────────────── */
#menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 199;
}
#sidebar-backdrop.visible { display: block; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  #menu-toggle { display: flex; }

  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  .page-wrap { padding: 20px 16px; }
  .dept-grid { grid-template-columns: 1fr 1fr; }
  .sections-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dash-tabs-bar { padding: 8px 12px 0; }
  .sheet-embed { height: 400px; }
  .kpi-col-row { flex-wrap: wrap; }
  .kpi-col-header { max-width: 100%; }
}
