/* =========================================================
   Host Titans — Design tokens
   Palette: graphite base + molten bronze/gold accent (Titan / forge motif)
   Display face: Space Grotesk (angular, structural — fits "Titans")
   Body face: Inter (quiet, legible for dense dashboard data)
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #F4F2EE;
  --surface: #FFFFFF;
  --surface-2: #FBFAF8;
  --border: #E4E0D8;
  --text: #1C1A16;
  --text-muted: #6B6558;
  --text-faint: #9B9484;

  --bronze: #B4682A;
  --bronze-dark: #8F4F1E;
  --gold: #D99A3D;
  --forge: #A83E2C;

  --ok: #2F7A4F;
  --ok-bg: #E7F3EA;
  --warn: #B4682A;
  --warn-bg: #FBEEE0;
  --danger: #B23A34;
  --danger-bg: #FBE9E7;
  --info: #35618C;
  --info-bg: #E8F0F7;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(28,26,22,0.06);
  --shadow-md: 0 6px 20px rgba(28,26,22,0.08);
  --sidebar-w: 248px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bg: #16140F;
  --surface: #1E1B15;
  --surface-2: #211D17;
  --border: #35301F;
  --text: #F2EEE4;
  --text-muted: #B4AB98;
  --text-faint: #7C7460;

  --ok-bg: #14261B;
  --warn-bg: #2C2013;
  --danger-bg: #2B1613;
  --info-bg: #16222C;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(180,104,42,0.16), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(217,154,61,0.14), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-brand .mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(145deg, var(--gold), var(--forge));
  display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.auth-brand span { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.auth-card h1 { font-size: 22px; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--text-muted); }
.auth-foot a { color: var(--bronze); font-weight: 600; }

/* ---------- Form elements ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  transition: border-color .15s;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { border-color: var(--bronze); outline: none; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(145deg, var(--gold), var(--bronze-dark)); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
  transition: transform .2s ease;
  z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-brand .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(145deg, var(--gold), var(--forge));
  display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.sidebar-brand span { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: 14px 10px 6px; font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--warn-bg); color: var(--bronze-dark); font-weight: 600; }
.nav-link .ic { width: 18px; text-align: center; flex-shrink: 0; }
.nav-link .badge-count {
  margin-left: auto; background: var(--forge); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.user-chip .who { min-width: 0; }
.user-chip .who .name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who .role { font-size: 11.5px; color: var(--text-faint); text-transform: capitalize; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; }
.topbar .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); display: grid; place-items: center; cursor: pointer; position: relative; font-size: 15px;
}
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--forge); border: 2px solid var(--surface-2); }
.menu-toggle { display: none; }

.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; }

/* ---------- Cards / stats / tables ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr);} }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 15.5px; }
.card-head .meta { font-size: 12.5px; color: var(--text-faint); }

.stat-card { padding: 20px; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-family: var(--font-display); font-size: 27px; font-weight: 700; margin-top: 8px; }
.stat-card .delta { font-size: 12.5px; margin-top: 6px; color: var(--text-faint); }
.stat-card .delta.up { color: var(--ok); }
.stat-card .icon-wrap {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 12px; font-size: 16px;
  background: var(--warn-bg); color: var(--bronze-dark);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.empty-row td { text-align: center; color: var(--text-faint); padding: 30px 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }

/* ---------- Share ring (signature element) ---------- */
.share-ring-wrap { display: flex; align-items: center; gap: 20px; }
.share-ring { position: relative; width: 118px; height: 118px; flex-shrink: 0; }
.share-ring svg { transform: rotate(-90deg); }
.share-ring .pct {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.share-ring .pct b { font-family: var(--font-display); font-size: 22px; }
.share-ring .pct small { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Notification dropdown ---------- */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: 46px; width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md);
  display: none; z-index: 50;
}
.dropdown-panel.open { display: block; }
.dropdown-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13.5px; display:flex; justify-content:space-between; align-items:center;}
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item:last-child { border-bottom: none; }
.notif-item .when { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.notif-item.unread { background: var(--warn-bg); }
.dropdown-empty { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------- Toggle switch (dark mode) ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .15s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--bronze); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-actions { display: flex; gap: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-faint); }
.empty-state .glyph { font-size: 30px; margin-bottom: 10px; }
.section-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 700; margin: 26px 0 12px; }
.bar-wrap { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bar-col .bar { width: 100%; max-width: 30px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--gold), var(--bronze-dark)); }
.bar-col .lbl { font-size: 10.5px; color: var(--text-faint); }
.chat-thread { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 75%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; }
.bubble.out { align-self: flex-end; background: linear-gradient(145deg, var(--gold), var(--bronze-dark)); color: #fff; border-bottom-right-radius: 3px; }
.bubble.in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.bubble .when { font-size: 10.5px; opacity: .75; margin-top: 5px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; display: none; }
.overlay.open { display: block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; }
  .content { padding: 20px 16px 50px; }
  .topbar { padding: 14px 16px; }
}
