
:root {
  /* Palette */
  --maroon:        #7a1520;
  --maroon-dark:   #2c0d10;
  --maroon-soft:   #9b2530;
  --gold:          #d4a017;
  --gold-soft:     #e6bf55;
  --bg:            #f4f2ef;
  --surface:       #ffffff;
  --surface-alt:   #faf8f5;
  --line:          #e7e2dc;
  --ink:           #241f1f;
  --ink-soft:      #6b625d;
  --ink-faint:     #9a918b;

  /* Status */
  --green:  #2e7d5b;
  --amber:  #d68a1e;
  --red:    #c0392b;
  --green-bg: #e8f4ee;
  --amber-bg: #fbf1de;
  --red-bg:   #fbeae7;
  --blue-bg:  #e8eef8;
  --blue:     #2f5aa8;

  /* Structure */
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 4px 18px rgba(44, 13, 16, 0.06);
  --shadow-lg: 0 10px 34px rgba(44, 13, 16, 0.10);
  --sidebar-w: 260px;

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Poppins', var(--font-body);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--maroon-dark), var(--maroon));
  color: #f3e9df;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { text-align: center; padding: 6px 0 18px; }
.brand__logo {
  width: 96px; height: 96px; margin: 0 auto 12px;
  border-radius: 50%; background: #fff;
  border: 3px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.brand__logo img { width: 100%; height: 100%; object-fit: cover; }
.brand__title { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; letter-spacing: .5px; }
.brand__sub { color: var(--gold-soft); font-size: .74rem; font-weight: 600; letter-spacing: 1px; margin-top: 2px; }
.brand__rule { width: 40px; height: 3px; background: var(--gold); border-radius: 2px; margin: 10px auto 0; }

.nav { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.nav__group { color: var(--gold-soft); font-size: .68rem; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; margin: 16px 10px 6px; }
.nav__link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: #eaded2; font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav__link i { width: 18px; text-align: center; font-size: .95rem; }
.nav__link:hover { background: rgba(255,255,255,.08); }
.nav__link.is-active { background: var(--maroon-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }

.sidebar__foot {
  margin-top: auto; padding: 14px;
  border: 1px solid rgba(212,160,23,.4);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  font-size: .8rem; color: #eaded2;
}
.sidebar__foot i { color: var(--gold); font-size: 1.2rem; }

/* ---- Main + topbar ------------------------------------------------ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px; background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__toggle {
  display: none; background: none; border: none; font-size: 1.3rem; color: var(--maroon);
}
.topbar__title { font-family: var(--font-head); font-weight: 700; color: var(--maroon); font-size: 1.18rem; line-height: 1.2; }
.topbar__sub { color: var(--ink-soft); font-size: .82rem; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.bell { position: relative; color: var(--ink-soft); font-size: 1.2rem; }
.bell__count {
  position: absolute; top: -7px; right: -8px;
  background: var(--red); color: #fff; font-size: .64rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.chip { display: flex; align-items: center; gap: 10px; }
.chip__avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--maroon); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.chip__name { font-weight: 600; font-size: .88rem; line-height: 1.1; }
.chip__role { font-size: .72rem; color: var(--ink-soft); }

/* ---- Content ------------------------------------------------------ */
.content { padding: 26px; flex: 1; }
.page-foot { text-align: center; color: var(--ink-faint); font-size: .78rem; padding: 18px; }

/* ---- Cards -------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card__head i { color: var(--maroon); }
.card__title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.card__link { margin-left: auto; color: var(--maroon); font-size: .82rem; font-weight: 600; }

.grid { display: grid; gap: 20px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 1024px){ .grid--2 { grid-template-columns: 1fr; } }

/* ---- Stat cards --------------------------------------------------- */
.stat { display: flex; align-items: center; gap: 14px; }
.stat__icon { width: 52px; height: 52px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat__icon--maroon { background: var(--red-bg); color: var(--maroon); }
.stat__icon--green  { background: var(--green-bg); color: var(--green); }
.stat__icon--gold   { background: var(--amber-bg); color: var(--amber); }
.stat__icon--blue   { background: var(--blue-bg); color: var(--blue); }
.stat__num { font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat__label { color: var(--ink-soft); font-size: .82rem; }

/* ---- Badges ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.badge--red   { background: var(--red-bg); color: var(--red); }
.badge--blue  { background: var(--blue-bg); color: var(--blue); }
.badge--gray  { background: #eee; color: var(--ink-soft); }

.risk-low  { color: var(--green); font-weight: 600; }
.risk-mod  { color: var(--amber); font-weight: 600; }
.risk-high { color: var(--red); font-weight: 600; }

/* ---- Tables ------------------------------------------------------- */
table.dt, .table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.table tr:last-child td { border-bottom: none; }

/* ---- Buttons ------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; font-size: .88rem; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--maroon); color: #fff; }
.btn--primary:hover { background: var(--maroon-soft); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--maroon); }
.btn--ghost:hover { border-color: var(--maroon); }
.btn--sm { padding: 7px 13px; font-size: .8rem; }
.btn--block { width: 100%; justify-content: center; }
.btn--green { background: #fff; border-color: var(--green); color: var(--green); }
.btn--green:hover { background: var(--green-bg); }
.btn--red { background: #fff; border-color: var(--red); color: var(--red); }
.btn--red:hover { background: var(--red-bg); }

/* ---- Forms -------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.field .req { color: var(--red); }
.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: .92rem; font-family: inherit;
  background: var(--surface); transition: border .15s, box-shadow .15s;
}
.input:focus, textarea.input:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(122,21,32,.10); }
textarea.input { resize: vertical; min-height: 110px; }

/* ---- Progress ring (SVG donut helper) ----------------------------- */
.ring { transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: var(--line); }
.ring__fg { fill: none; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* ---- Login split screen ------------------------------------------ */
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login__brand {
  background: linear-gradient(160deg, var(--maroon-dark), #3d1216);
  color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 40px;
}
.login__brand .brand__logo { width: 150px; height: 150px; }
.login__brand h1 { font-family: var(--font-head); font-size: 2.1rem; margin-top: 8px; }
.login__brand .tag { color: var(--gold); font-weight: 700; font-size: 1.05rem; margin-top: 12px; max-width: 320px; }
.login__brand .org { color: #d9c9bd; margin-top: 10px; font-size: .92rem; }
.login__brand .quote { color: #a98c86; font-style: italic; margin-top: 30px; }
.login__form { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface-alt); }
.login__form-inner { width: 100%; max-width: 380px; }
.login__form-inner h2 { font-family: var(--font-head); font-size: 1.9rem; }
.login__form-inner p.lead { color: var(--ink-soft); margin: 4px 0 26px; }
.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--ink-faint); font-size: 1rem; }
.form-error { background: var(--red-bg); color: var(--red); padding: 11px 14px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 16px; }

@media (max-width: 800px){
  .login { grid-template-columns: 1fr; }
  .login__brand { padding: 40px 24px; min-height: 40vh; }
}

/* ---- Mobile sidebar drawer --------------------------------------- */
.backdrop { display: none; }
@media (max-width: 900px){
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .topbar__toggle { display: block; }
  .backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
}

.helper-note { color: var(--ink-soft); font-size: .8rem; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

/* ---- Notification dropdown (Phase 9) ------------------------------ */
.notif-panel {
  position: absolute; top: 140%; right: 0; width: 340px; max-width: 88vw;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .15s, transform .15s, visibility .15s; z-index: 80;
  overflow: hidden; text-align: left; cursor: default;
}
.notif-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-family: var(--font-head); color: var(--maroon);
}
.notif-markall { background: none; border: none; color: var(--maroon); font-size: .76rem; font-weight: 600; cursor: pointer; }
.notif-markall:hover { text-decoration: underline; }
.notif-panel__body { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-alt); }
.notif-item.is-unread { background: #fbf3f2; }
.notif-item.is-unread:hover { background: #f7e9e7; }
.notif-item > i { color: var(--maroon); margin-top: 2px; font-size: .9rem; }
.notif-item__title { font-weight: 600; font-size: .84rem; }
.notif-item__msg { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }
.notif-empty { padding: 22px; text-align: center; color: var(--ink-faint); font-size: .85rem; }
.notif-panel__foot { display: block; text-align: center; padding: 11px; font-size: .82rem; font-weight: 600; color: var(--maroon); border-top: 1px solid var(--line); }
.notif-panel__foot:hover { background: var(--surface-alt); }
