/* ============================================================
   MERIDIAN ADMIN — Light Silver Edition
   Clean light background · Navy & Gold · Large readable UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --navy-950: #020b18;
  --navy-900: #04111f;
  --navy-800: #0a2035;
  --navy-700: #123a5c;
  --navy-600: #1a4f7a;
  --navy-500: #226498;
  --navy-400: #3a80b8;
  --navy-300: #6aaad8;
  --navy-200: #a8ccec;
  --navy-100: #deeef8;

  --gold-600: #8a6500;
  --gold-500: #b08400;
  --gold-400: #c9950f;
  --gold-300: #d4a827;
  --gold-200: #e8cc6a;
  --gold-100: #faefc4;

  /* LIGHT SURFACES */
  --bg-base:    #eef0f4;
  --bg-surface: #ffffff;
  --bg-card:    #ffffff;
  --bg-raised:  #f4f6fa;
  --bg-hover:   #eaecf2;
  --bg-active:  #e0e6f0;

  --border-subtle:      rgba(20, 50, 90, 0.08);
  --border-soft:        rgba(20, 50, 90, 0.14);
  --border-mid:         rgba(20, 50, 90, 0.22);
  --border-gold:        rgba(201, 149, 15, 0.4);
  --border-gold-strong: rgba(201, 149, 15, 0.65);

  --text-primary:   #0d1e33;
  --text-secondary: #2c4a6a;
  --text-muted:     #6b85a0;
  --text-disabled:  #b0c4d8;

  --green:      #1a7a4a;
  --green-bg:   rgba(26,122,74,0.1);
  --red:        #b83030;
  --red-bg:     rgba(184,48,48,0.1);
  --amber:      #b07010;
  --amber-bg:   rgba(176,112,16,0.1);
  --blue:       var(--navy-500);
  --blue-bg:    rgba(34,100,152,0.1);

  --shadow-sm:   0 1px 4px rgba(10,30,60,0.09);
  --shadow-md:   0 4px 16px rgba(10,30,60,0.11);
  --shadow-lg:   0 10px 36px rgba(10,30,60,0.14);

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;

  --sidebar-w:        184px;
  --sidebar-w-collapsed: 58px;
  --topbar-h:   68px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --transition:    0.16s ease;
  --transition-md: 0.26s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }  /* bigger base */
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.2;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-raised); }
::-webkit-scrollbar-thumb { background: var(--navy-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-300); }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition-md);
  overflow: visible;
}
.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--navy-700), var(--gold-400), var(--navy-400));
}

.sidebar-logo {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 12px;
}
.logo-mark {
  width: 40px; height: 40px;
  background: var(--navy-800); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-mark svg { width: 22px; height: 22px; fill: var(--gold-300); }
.logo-text {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--navy-900);
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--transition-md), max-width var(--transition-md);
  max-width: 200px; opacity: 1;
}
.logo-text span { color: var(--gold-500); }

.sidebar-section { padding: 18px 12px 4px; }
.sidebar-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0 10px; margin-bottom: 6px; font-family: var(--font-mono);
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  color: var(--text-secondary);
  font-size: 0.96rem; font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all var(--transition); margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--navy-800); border-left-color: var(--border-mid); }
.nav-item.active { background: var(--bg-active)!important; color: var(--navy-800)!important; border-left-color: var(--gold-400)!important; font-weight: 600!important;}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted)!important; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: var(--navy-600)!important; }
.nav-badge {
  margin-left: auto; background: var(--navy-100); color: var(--navy-700);
  border: 1px solid var(--navy-200); font-size: 0.62rem; font-weight: 700;
  padding: 2px 7px; font-family: var(--font-mono); border-radius: var(--radius-sm);
}

/* Nav label — smooth hide on collapse */
.nav-label {
  white-space: normal;
  overflow: visible;
  transition: opacity var(--transition-md), max-width var(--transition-md);
  max-width: 200px;
  opacity: 1;
  line-height: 1.3;
}

.sidebar-footer { margin-top: auto; padding: 16px 12px; border-top: 1px solid var(--border-subtle); }
.user-card { display: flex; align-items: center; gap: 11px; padding: 10px; cursor: pointer; border-radius: var(--radius-md); transition: background var(--transition); }
.user-card:hover { background: var(--bg-hover); }

.avatar {
  width: 38px; height: 38px; background: var(--navy-800); border: 2px solid var(--gold-300);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: var(--gold-200);
  flex-shrink: 0; font-family: var(--font-mono);
}
.avatar.sm { width: 34px; height: 34px; font-size: 0.72rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }

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

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; padding: 0 30px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--navy-900); }
.breadcrumb { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); }
.breadcrumb span { color: var(--text-secondary); }
.breadcrumb-sep { opacity: 0.4; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  width: 40px; height: 40px; border: 1px solid var(--border-soft); background: var(--bg-raised);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); font-size: 16px;
  transition: all var(--transition); position: relative;
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--border-mid); color: var(--navy-700); box-shadow: var(--shadow-sm); }
.notif-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; background: var(--gold-400); border-radius: 50%; border: 2px solid var(--bg-surface); }

/* Page */
.page { padding: 10px 12px; flex: 1; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.page-header { margin-bottom: 5px; }
.page-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; color: var(--navy-900); margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 0.94rem; }
.page-title-rule { height: 2px; width: 150px; background: var(--gold-400); margin: 8px 0 0; border-radius: 2px; }

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 24px 26px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-soft); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--navy-900); }
.card-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }

/* Stat Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 22px 24px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: all var(--transition-md);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.stat-card.gold::before  { background: var(--gold-400); }
.stat-card.blue::before  { background: var(--navy-500); }
.stat-card.green::before { background: var(--green); }
.stat-card.red::before   { background: var(--red); }

.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.stat-icon.gold  { background: rgba(201,149,15,0.12); }
.stat-icon.blue  { background: rgba(34,100,152,0.1); }
.stat-icon.green { background: rgba(26,122,74,0.1); }
.stat-icon.red   { background: rgba(184,48,48,0.1); }

.stat-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-mono); margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--navy-900); line-height: 1; letter-spacing: -0.02em; margin-bottom: 10px; }
.stat-change { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.stat-change.up   { background: var(--green-bg); color: var(--green); }
.stat-change.down { background: var(--red-bg);   color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-md);
  transition: all var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--navy-800); color: #fff; border-color: var(--navy-800); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); border-color: var(--navy-700); box-shadow: var(--shadow-md); }

.btn-gold { background: var(--gold-400); color: var(--navy-950); border-color: var(--gold-400); box-shadow: var(--shadow-sm); }
.btn-gold:hover:not(:disabled) { background: var(--gold-300); }

.btn-secondary { background: var(--bg-raised); color: var(--text-primary); border-color: var(--border-mid); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); box-shadow: var(--shadow-sm); }

.btn-outline { background: transparent; color: var(--navy-700); border-color: var(--navy-300); }
.btn-outline:hover:not(:disabled) { background: var(--navy-100); border-color: var(--navy-400); }

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

.btn-danger  { background: var(--red-bg);   color: var(--red);   border-color: rgba(184,48,48,0.3); }
.btn-danger:hover:not(:disabled)  { background: rgba(184,48,48,0.18); }

.btn-success { background: var(--green-bg); color: var(--green); border-color: rgba(26,122,74,0.3); }
.btn-success:hover:not(:disabled) { background: rgba(26,122,74,0.18); }

.btn-sm { padding: 8px 16px; font-size: 0.84rem; }
.btn-lg { padding: 14px 30px; font-size: 1.05rem; }
.btn-icon { padding: 10px 12px; }
.btn-icon.sm { padding: 7px 9px; }

/* Forms — bigger */
.form-group { display: flex; flex-direction: column; gap: 7px; margin-bottom: 22px; }
.form-label { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }
.form-label .required { color: var(--gold-500); margin-left: 3px; }

.form-control {
  background: var(--bg-raised);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 13px 16px;          /* bigger */
  color: var(--text-primary);
  font-size: 0.96rem;           /* bigger */
  font-family: var(--font-body);
  transition: all var(--transition); outline: none; width: 100%;
}
.form-control::placeholder { color: var(--text-disabled); }
.form-control:focus { border-color: var(--navy-500); background: #fff; box-shadow: 0 0 0 3px rgba(34,100,152,0.12); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg-hover); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }

.input-wrap { position: relative; }
.input-wrap .input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; font-size: 16px; }
.input-wrap .form-control { padding-left: 42px; }
.input-wrap.right .input-icon { left: auto; right: 14px; }
.input-wrap.right .form-control { padding-left: 16px; padding-right: 42px; }

.form-hint  { font-size: 0.8rem; color: var(--text-muted); }
.form-error { font-size: 0.8rem; color: var(--red); }
.form-control.error { border-color: var(--red); }

.check-group, .radio-group { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; font-size: 0.95rem; }
.check-group input, .radio-group input { width: 18px; height: 18px; accent-color: var(--navy-600); cursor: pointer; }

.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle { width: 48px; height: 26px; background: var(--bg-hover); border: 1.5px solid var(--border-soft); border-radius: 13px; position: relative; cursor: pointer; transition: background var(--transition); flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted); transition: all var(--transition); }
.toggle.on { background: var(--navy-600); border-color: var(--navy-500); }
.toggle.on::after { left: 24px; background: #fff; }

input[type="range"] { width: 100%; height: 6px; background: var(--bg-hover); outline: none; border: none; cursor: pointer; accent-color: var(--navy-600); border-radius: 3px; }
input[type="color"] { width: 48px; height: 46px; border: 1.5px solid var(--border-soft); border-radius: var(--radius-md); cursor: pointer; background: var(--bg-raised); padding: 3px; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
thead tr { border-bottom: 2px solid var(--border-soft); }
thead th { background: var(--bg-raised); padding: 14px 18px; text-align: left; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono); }
thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-raised); }
tbody td { padding: 4px 8px; font-size: 0.92rem; color: var(--text-secondary); vertical-align: middle; }
.td-primary { font-weight: 600; color: var(--text-primary); }
.td-mono    { font-family: var(--font-mono); font-size: 0.84rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; font-family: var(--font-mono); }
.badge-gold  { background: rgba(201,149,15,0.1);  color: var(--gold-600);  border: 1px solid rgba(201,149,15,0.3); }
.badge-green { background: var(--green-bg);        color: var(--green);     border: 1px solid rgba(26,122,74,0.25); }
.badge-red   { background: var(--red-bg);          color: var(--red);       border: 1px solid rgba(184,48,48,0.25); }
.badge-blue  { background: var(--blue-bg);         color: var(--navy-600);  border: 1px solid rgba(34,100,152,0.25); }
.badge-amber { background: var(--amber-bg);        color: var(--amber);     border: 1px solid rgba(176,112,16,0.25); }
.badge-muted { background: var(--bg-hover);        color: var(--text-muted);border: 1px solid var(--border-soft); }
.badge-navy  { background: rgba(10,32,53,0.07);    color: var(--navy-700);  border: 1px solid var(--navy-200); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn { min-width: 38px; height: 38px; border: 1px solid var(--border-soft); background: var(--bg-card); color: var(--text-secondary); font-size: 0.88rem; font-weight: 600; cursor: pointer; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; padding: 0 10px; transition: all var(--transition); }
.page-btn:hover { background: var(--bg-hover); border-color: var(--border-mid); color: var(--text-primary); }
.page-btn.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; font-weight: 700; box-shadow: var(--shadow-sm); }

/* Search bar */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--bg-raised); border: 1.5px solid var(--border-soft); border-radius: var(--radius-md); padding: 10px 16px; transition: all var(--transition); }
.search-bar:focus-within { border-color: var(--navy-500); background: #fff; box-shadow: 0 0 0 3px rgba(34,100,152,0.1); }
.search-bar input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 0.94rem; flex: 1; min-width: 160px; }
.search-bar input::placeholder { color: var(--text-muted); }

/* Progress */
.progress { height: 7px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--navy-600); transition: width 0.5s ease; }
.progress-bar.gold  { background: var(--gold-400); }
.progress-bar.green { background: var(--green); }

/* Alert */
.alert { padding: 14px 18px; border-left: 4px solid; border-radius: 0 var(--radius-md) var(--radius-md) 0; font-size: 0.92rem; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
.alert-info    { background: var(--blue-bg);  border-color: var(--navy-500); color: var(--navy-700); }
.alert-success { background: var(--green-bg); border-color: var(--green);    color: var(--green); }
.alert-warning { background: var(--amber-bg); border-color: var(--amber);    color: var(--amber); }
.alert-danger  { background: var(--red-bg);   border-color: var(--red);      color: var(--red); }

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

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: calc(100%+6px); left: 50%; transform: translateX(-50%); background: var(--navy-900); color: #fff; font-size: 0.74rem; padding: 5px 10px; border-radius: var(--radius-sm); white-space: nowrap; pointer-events: none; z-index: 999; box-shadow: var(--shadow-md); }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2,1fr); }
.grid-3 { grid-template-columns: repeat(3,1fr); }
.grid-4 { grid-template-columns: repeat(4,1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); }

/* Utils */
.flex            { display: flex; }
.flex-col        { display: flex; flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mb-4   { margin-bottom: 16px; }
.mb-5   { margin-bottom: 20px; }
.mb-6   { margin-bottom: 24px; }
.mt-4   { margin-top: 16px; }
.text-sm   { font-size: 0.88rem; }
.text-xs   { font-size: 0.76rem; }
.text-muted{ color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.w-full    { width: 100%; }
.uppercase { text-transform: uppercase; letter-spacing: 0.07em; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   SUBMENU — Accordion sidebar nav
   ============================================================ */

/* Parent item that has children: don't navigate, just toggle */
.nav-item.has-submenu {
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
}

/* Arrow indicator on the right */
.nav-item.has-submenu .nav-arrow {
  margin-left: auto;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-md);
}

/* Rotate arrow when open */
.nav-item.has-submenu.open .nav-arrow {
  transform: rotate(90deg);
  color: var(--navy-600);
}

/* The submenu container — hidden by default */
.submenu {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
  padding-left: 0;
}

/* Expanded state */
.nav-item.has-submenu.open .submenu {
  max-height: 400px; /* large enough for any submenu */
}

/* Individual submenu links */
.submenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 38px; /* indented */
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all var(--transition);
  margin-bottom: 1px;
}
.submenu-item:hover {
  background: var(--bg-hover);
  color: var(--navy-800);
  border-left-color: var(--border-mid);
}
.submenu-item.active {
  background: var(--bg-active);
  color: var(--navy-800);
  border-left-color: var(--gold-400);
  font-weight: 600;
}

/* Dot marker for submenu items */
.submenu-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}
.submenu-item:hover .submenu-dot,
.submenu-item.active .submenu-dot {
  background: var(--gold-400);
}
/* ============================================================
   COLLAPSED SIDEBAR
   ============================================================ */

/* Toggle button — sits at bottom of sidebar */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 12px 14px;
  padding: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--navy-700);
  border-color: var(--border-mid);
}
.sidebar-toggle-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform var(--transition-md);
}
.sidebar-toggle-btn .toggle-label {
  transition: opacity var(--transition-md), max-width var(--transition-md);
  opacity: 1;
  max-width: 100px;
  overflow: hidden;
  white-space: nowrap;
}

/* ---- COLLAPSED STATE on <body> ---- */
body.sidebar-collapsed .sidebar           { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main-content      { margin-left: var(--sidebar-w-collapsed); }

/* Hide text labels */
body.sidebar-collapsed .nav-label         { opacity: 0; max-width: 0; overflow: hidden; white-space: nowrap; }
body.sidebar-collapsed .logo-text         { opacity: 0; max-width: 0; overflow: hidden; }
body.sidebar-collapsed .sidebar-label     { display: none; }
body.sidebar-collapsed .sidebar-footer    { padding: 10px 6px; }
body.sidebar-collapsed .user-card         { justify-content: center; padding: 6px; gap: 0; }
body.sidebar-collapsed .user-info         { display: none; }
body.sidebar-collapsed .sidebar-toggle-btn .toggle-label { opacity: 0; max-width: 0; }

/* Centre icons when collapsed */
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
  gap: 0;
  position: relative;
  overflow: visible;
}

/* Rotate the toggle arrow when collapsed */
body.sidebar-collapsed .sidebar-toggle-btn svg { transform: rotate(180deg); }

/* Hide submenu arrow in collapsed mode */
body.sidebar-collapsed .nav-arrow { display: none; }

/* In collapsed mode — submenus fly out to the right on hover */
body.sidebar-collapsed .nav-item.has-submenu { flex-wrap: nowrap; }

/* Force .open class to have NO effect in collapsed mode */
body.sidebar-collapsed .nav-item.has-submenu.open .submenu {
  max-height: 0;
  padding: 0;
  border-color: transparent;
  box-shadow: none;
}

body.sidebar-collapsed .submenu {
  display: block;
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) + 6px);
  top: 0;
  max-height: 0;
  overflow: hidden;
  background: var(--bg-surface);
  /*border: 1px solid transparent;*/
  border-radius: var(--radius-md);
  box-shadow: none;
  min-width: 180px;
  z-index: 300;
  transition: max-height 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease, padding 0.28s ease;
  padding: 0;
}

body.sidebar-collapsed .nav-item.has-submenu:hover .submenu {
  max-height: 400px;
  padding: 4px 0;
  border-color: var(--border-soft);
  box-shadow: var(--shadow-md);
}

/* Submenu items in flyout */
body.sidebar-collapsed .submenu .submenu-item {
  padding: 9px 16px;
  white-space: nowrap;
}

/* Tooltip on hover for regular items when collapsed */
body.sidebar-collapsed .nav-item:not(.has-submenu):hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy-900);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  z-index: 300;
  box-shadow: var(--shadow-md);
}
/* Small left arrow on tooltip */
body.sidebar-collapsed .nav-item:not(.has-submenu):hover::before {
  content: '';
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) - 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--navy-900);
  pointer-events: none;
  z-index: 301;
}