/* ─── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette */
  --primary:        #b16f5a;           /* terracotta */
  --primary-dark:   #96513f;
  --primary-hover:  #c0806b;
  --primary-light:  #f5ede9;
  --primary-ring:   rgba(177, 111, 90, 0.18);

  --secondary:      #1f5431;           /* dark green */
  --secondary-dark: #163d22;
  --secondary-hover:#2a6e40;

  --light-green:    #c7d4cc;
  --muted-green:    #8faa98;

  --gray:           #ababab;

  /* Text */
  --text:           #2b3a2c;
  --text-muted:     #6b7a6c;
  --text-light:     #9aab9e;

  /* Surfaces */
  --bg:             #ebdcc1;           /* cream */
  --card:           #ffffff;
  --border:         #d9ceae;

  /* Status */
  --success:        #1f5431;
  --success-light:  #d0e8d8;
  --warning:        #a87828;
  --warning-light:  #fdefd5;
  --danger:         #c0392b;
  --danger-light:   #fde8e6;

  /* Layout */
  --sidebar-w:      264px;
  --header-h:       64px;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 12px 36px rgba(0,0,0,.13), 0 4px 10px rgba(0,0,0,.06);
}

/* ─── Typography ────────────────────────────────────────────────────────────── */
body {
  font-family: 'Muller', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3, h4 {
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
  font-weight: 700;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--secondary);      /* dark green */
  color: rgba(255,255,255,.75);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,.09);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.brand-text .name {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.1px;
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
}

.brand-text .tagline {
  font-size: 10.5px;
  color: rgba(255,255,255,.38);
  margin-top: 2px;
  letter-spacing: .2px;
}

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.32);
  padding: 14px 24px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 24px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
}

.nav-link.active {
  color: #fff;
  background: rgba(177,111,90,.22);    /* terracotta tint */
  border-left-color: var(--primary);   /* terracotta accent line */
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: .75;
}

.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,.09);
}

.user-block {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-block .info .uname {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.user-block .info .urole {
  font-size: 11px;
  color: rgba(255,255,255,.38);
  text-transform: capitalize;
}

.sign-out {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,.38);
  text-decoration: none;
  transition: color .15s;
}

.sign-out:hover { color: #ff8a80; }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ─── Main Layout ───────────────────────────────────────────────────────────── */
.layout {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-muted);
  line-height: 0;
  transition: background .15s;
}

.hamburger:hover { background: var(--bg); }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
  letter-spacing: -.1px;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ─── Content ───────────────────────────────────────────────────────────────── */
.content { padding: 28px 28px 52px; flex: 1; }

/* ─── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  font-weight: 500;
}

.alert-error   { background: var(--danger-light);  color: #922b21; border: 1px solid #f5c6c2; }
.alert-success { background: var(--success-light); color: #1a4226; border: 1px solid #a8d8b4; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #e4beb4; }

/* ─── Stat Cards ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card.primary { background: var(--primary); }  /* terracotta */

.stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
}

.stat-card.primary .stat-label { color: rgba(255,255,255,.72); }

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
}

.stat-card.primary .stat-value { color: white; }

.stat-value .unit {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  font-family: 'Muller', 'DM Sans', sans-serif;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-light);
}

.stat-card.primary .stat-sub { color: rgba(255,255,255,.62); }

/* ─── Progress Bar ──────────────────────────────────────────────────────────── */
.progress {
  height: 5px;
  background: rgba(0,0,0,.07);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.stat-card.primary .progress { background: rgba(255,255,255,.28); }

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width .4s ease;
}

.stat-card.primary .progress-fill { background: rgba(255,255,255,.85); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
}

.card-body { padding: 24px; }

/* ─── Chart ─────────────────────────────────────────────────────────────────── */
.chart-wrap { height: 290px; position: relative; }

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: #f8f2e5;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f0ead8;
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #faf6ee; }

tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--text);
}

/* ─── Advisor Cell ──────────────────────────────────────────────────────────── */
.advisor-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.advisor-cell .info .primary-text { font-weight: 600; font-size: 14px; }
.advisor-cell .info .secondary-text { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }
.badge-success  { background: var(--success-light); color: #1a4226; }
.badge-warning  { background: var(--warning-light); color: #7a5010; }
.badge-danger   { background: var(--danger-light);  color: #922b21; }
.badge-neutral  { background: var(--light-green);   color: var(--secondary); }

/* ─── Utilization Bar in Table ──────────────────────────────────────────────── */
.util-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.util-bar { flex: 1; height: 6px; background: var(--light-green); border-radius: 3px; overflow: hidden; }
.util-bar .fill { height: 100%; border-radius: 3px; background: var(--muted-green); }
.util-bar .fill.warning { background: var(--primary); }   /* terracotta at high usage */
.util-bar .fill.danger  { background: var(--danger); }
.util-pct { font-size: 12px; color: var(--text-muted); width: 36px; text-align: right; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--primary);          /* terracotta */
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline {
  background: white;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover { background: #f9f4ea; border-color: #c4b99a; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--text); }

.btn-success {
  background: var(--secondary);        /* dark green */
  color: white;
  border-color: var(--secondary);
}

.btn-success:hover { background: var(--secondary-dark); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Back Link ─────────────────────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
  transition: color .15s;
}

.back-link:hover { color: var(--primary); }
.back-link svg { width: 15px; height: 15px; }

/* ─── Advisor Banner (Admin view) ───────────────────────────────────────────── */
.advisor-banner {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.advisor-banner .avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.advisor-banner .advisor-info h2 {
  font-size: 19px;
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
}

.advisor-banner .advisor-info p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.advisor-banner .actions { margin-left: auto; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

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

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
  font-family: 'Muller', 'DM Sans', sans-serif;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }

/* ─── Auth Pages ────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);             /* cream */
  padding: 24px;
  position: relative;
}

.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 20%, rgba(177,111,90,.14) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(31,84,49,.11) 0%, transparent 55%);
  pointer-events: none;
}

.auth-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 54px;
  height: 54px;
  background: var(--secondary);       /* dark green */
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 26px;
  box-shadow: 0 4px 14px rgba(31,84,49,.32);
}

.auth-logo h1 {
  font-size: 22px;
  color: var(--text);
  letter-spacing: -.2px;
}

.auth-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.auth-card > h2 {
  font-size: 19px;
  color: var(--text);
  margin-bottom: 22px;
}

.demo-box {
  margin-top: 22px;
  padding: 14px 16px;
  background: #f8f3e8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

.demo-box strong { color: var(--secondary); }

/* ─── Table Toolbar ─────────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color .15s;
  width: 200px;
  font-family: 'Muller', 'DM Sans', sans-serif;
}

.toolbar-input:focus { border-color: var(--primary); }
.toolbar-select { width: 160px; }

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-bg.show { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal-box h3 {
  font-size: 18px;
  margin-bottom: 6px;
  font-family: 'Costa PTF', 'Playfair Display', Georgia, serif;
}

.modal-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

.link-row { display: flex; gap: 8px; align-items: stretch; }

.link-input {
  flex: 1;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #f8f3e8;
  color: var(--text);
  outline: none;
}

.copy-msg {
  font-size: 12px;
  color: var(--success);
  margin-top: 8px;
  display: none;
  font-weight: 500;
}

.modal-footer { margin-top: 16px; display: flex; gap: 8px; }

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: 14px; }

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

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .layout { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 18px 16px 36px; }
  .topbar { padding: 0 16px; }
  .advisor-banner { gap: 12px; }
  .advisor-banner .actions { margin-left: 0; width: 100%; }
  .advisor-banner .actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 580px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 22px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .table-toolbar { width: 100%; }
  .toolbar-input, .toolbar-select { width: 100%; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}
