:root {
  --bg: #0a0b0d;
  --panel: #141619;
  --panel-2: #1b1e23;
  --raised: #20242b;
  --border: #2a2f37;
  --text: #e9eaed;
  --muted: #888e99;
  --gold: #d4af37;          /* metallic gold accent */
  --gold-soft: rgba(212,175,55,0.12);
  --ink: #17130a;           /* text on gold */
  --healthy: #46b955;
  --degraded: #e0a72c;
  --down: #e5534b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ============ LEFT SIDEBAR ============ */
.sidebar {
  width: 236px; flex-shrink: 0; background: #0d0f12;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 20px; }
.brand-logo { height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 32px; font-weight: 700; letter-spacing: 0.5px; line-height: 1; }
.brand-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-group { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; padding: 8px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; text-align: left;
  background: transparent; border: none; color: var(--muted);
  padding: 10px 12px; border-radius: 9px; font-size: 14px; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-ic { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; opacity: 0.9; }
.nav-ic svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--gold-soft); color: var(--gold); }
.nav-item.active .nav-ic { opacity: 1; }
.nav-item.build.active { color: var(--gold); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.sys-mini { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.sys-mini .sd { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }

/* ============ CENTER WORKSPACE ============ */
.workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 30px 11px; border-bottom: 1px solid var(--border);
}
.module-title { margin: 0; font-size: 19px; font-weight: 600; }
.health-pill { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px; display: flex; align-items: center; gap: 7px; }

.workspace-body { flex: 1; overflow-y: auto; padding: 26px 30px; }

/* Executive dashboard sections */
.greeting { margin-bottom: 22px; }
.greeting h2 { margin: 0 0 4px; font-size: 26px; font-weight: 650; }
.greeting p { margin: 0; color: var(--muted); font-size: 14.5px; }

.section { margin-bottom: 26px; }
.section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.3px; margin: 0 0 12px; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }

.health-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.kpi { padding: 22px; display: flex; flex-direction: column; gap: 3px; min-height: 150px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-ic { color: var(--gold); display: flex; align-items: center; }
.kpi-ic svg { width: 22px; height: 22px; }
.kpi-period { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.kpi-title { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.kpi-metric { font-size: 38px; font-weight: 750; line-height: 1.05; margin-top: 4px; display: flex; align-items: baseline; gap: 9px; }
.kpi-trend { font-size: 12.5px; font-weight: 700; }
.kpi-trend.up { color: var(--healthy); }
.kpi-trend.down { color: var(--down); }
.kpi-trend.flat { color: var(--muted); }
.kpi-note { font-size: 11.5px; color: var(--gold); opacity: 0.85; margin-top: auto; }
.sys-strip { display: flex; gap: 24px; flex-wrap: wrap; padding: 4px 2px 20px; border-bottom: 1px solid var(--border); margin-bottom: 22px; font-size: 12.5px; color: var(--muted); }
.sys-strip .ss-item { display: flex; align-items: center; gap: 7px; }
.sys-strip b { color: var(--text); font-weight: 650; }
@media (max-width: 1100px) { .kpi-cards { grid-template-columns: repeat(2, 1fr); } }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col .section { margin-bottom: 0; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.hcard { padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.hcard-top { display: flex; align-items: center; justify-content: space-between; }
.hcard-ic { font-size: 18px; color: var(--gold); }
.hcard-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.hcard-metric { font-size: 27px; font-weight: 700; line-height: 1.1; }
.hcard-detail { font-size: 12.5px; color: var(--muted); }

.feature-card { padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start; }
.feature-card .obj-title { font-size: 19px; font-weight: 650; margin: 0 0 6px; }
.feature-card .obj-desc { color: var(--muted); font-size: 14px; margin: 0 0 14px; max-width: 640px; }
.progress { height: 8px; background: var(--raised); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > span { display: block; height: 100%; background: var(--gold); }
.obj-meta { display: flex; gap: 26px; flex-wrap: wrap; font-size: 13px; }
.obj-meta .k { color: var(--muted); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.obj-side { text-align: right; color: var(--muted); font-size: 13px; }

.list-card { padding: 6px 18px; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .row-title { font-size: 14px; }
.row .row-sub { font-size: 12px; color: var(--muted); }
.row .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.gold { color: var(--gold); border-color: rgba(212,175,55,0.4); background: var(--gold-soft); }

.rec-metrics { display: flex; gap: 16px; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.rec-metrics b { color: var(--text); font-weight: 600; }

.btn { border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text); }
.btn.gold { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn:disabled { opacity: 0.45; cursor: default; }

.empty { color: var(--muted); font-size: 13.5px; padding: 6px 0; }
.count { background: var(--gold); color: var(--ink); border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.clickable { cursor: pointer; }
.clickable:hover { background: rgba(255,255,255,0.025); }

/* Builder cockpit */
.builder-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.assign-form { flex-direction: column; gap: 10px; margin-bottom: 22px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.assign-form input, .assign-form textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; }
.assign-form input:focus, .assign-form textarea:focus { outline: none; border-color: var(--gold); }
.assign-form button { align-self: flex-start; }
.obj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 24px; }
.obj-card { padding: 16px; }
.obj-card.sel { border-color: var(--gold); }
.oc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.oc-title { font-size: 14.5px; font-weight: 600; }
.plan-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 13.5px; margin-top: 6px; max-height: 320px; overflow-y: auto; }
.plan-box ul { padding-left: 18px; margin: 4px 0; }

/* Placeholder department modules */
.placeholder-module { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; color: var(--muted); }
.placeholder-module .pm-ic { font-size: 40px; color: var(--gold); opacity: 0.8; margin-bottom: 14px; }
.placeholder-module h2 { color: var(--text); margin: 0 0 8px; font-size: 22px; }
.placeholder-module p { max-width: 460px; margin: 0 0 6px; }
.placeholder-module .soon { margin-top: 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gold); border: 1px solid rgba(212,175,55,0.4); border-radius: 999px; padding: 5px 14px; }

/* ============ ASK COIN DOCK ============ */
.askcoin-dock { border-top: 1px solid var(--border); background: #0d0f12; padding: 12px 30px 16px; display: flex; flex-direction: column; gap: 8px; }
.askcoin-head { display: flex; align-items: baseline; gap: 12px; }
.askcoin-label { font-size: 12px; font-weight: 700; letter-spacing: 0.5px; color: var(--gold); }
.askcoin-hint { font-size: 11.5px; color: var(--muted); }
.askcoin-log { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.askcoin-log:empty { display: none; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 11px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--gold); color: var(--ink); border-bottom-right-radius: 3px; }
.msg.coin { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg.coin ul { margin: 4px 0; padding-left: 18px; }
.msg.pending { color: var(--muted); font-style: italic; }
.cursor { color: var(--gold); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.askcoin-input { display: flex; gap: 10px; align-items: center; }
.askcoin-input input[type=text] { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; color: var(--text); font-size: 14px; }
.askcoin-input input[type=text]:focus { outline: none; border-color: var(--gold); }
.askcoin-input button { background: var(--gold); color: var(--ink); border: none; border-radius: 10px; padding: 0 20px; height: 42px; font-size: 14px; font-weight: 700; cursor: pointer; }
.askcoin-input button:disabled { opacity: 0.5; cursor: default; }
.attach { display: flex; align-items: center; font-size: 18px; cursor: pointer; color: var(--muted); user-select: none; }
.workspace-foot { text-align: center; padding: 12px 30px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }
.attach:hover { color: var(--gold); }

/* review card (file upload) */
.review-card { max-width: 92%; }
.review-meta { color: var(--muted); font-size: 12px; margin: 4px 0; }
.review-warn { color: var(--degraded); font-size: 12px; margin: 4px 0; }
.review-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; font-size: 12px; max-height: 130px; overflow-y: auto; white-space: pre-wrap; color: var(--muted); }
.review-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.review-actions select { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 5px 8px; }
.btn-approve { background: var(--healthy); color: #06210c; border: none; border-radius: 6px; padding: 7px 14px; font-weight: 600; cursor: pointer; }
.btn-reject { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 7px 14px; cursor: pointer; }

/* ============ RIGHT BUILDER RAIL ============ */
.builder-rail { width: 330px; flex-shrink: 0; background: #0d0f12; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 14px; border-bottom: 1px solid var(--border); }
.rail-title { font-size: 14px; font-weight: 700; letter-spacing: 0.4px; }
.rail-open { background: transparent; border: none; color: var(--gold); font-size: 12px; cursor: pointer; }
.rail-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.rail-block .rb-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.rail-block .rb-value { font-size: 14px; }
.rail-actions { display: flex; flex-direction: column; gap: 8px; }
.rail-actions .btn { width: 100%; text-align: left; }

/* status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.healthy { background: var(--healthy); } .dot.degraded { background: var(--degraded); }
.dot.unavailable, .dot.down { background: var(--down); } .dot.planned { background: var(--muted); }
.state-txt { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.muted { color: var(--muted); }

@media (max-width: 1200px) { .builder-rail { width: 280px; } .health-cards { grid-template-columns: repeat(2, 1fr); } }

/* ---------------- authentication ---------------- */
#auth-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 800px at 50% -10%, #16181d 0%, var(--bg) 60%);
}
.auth-card {
  width: 360px; max-width: 90vw;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-logo { width: 300px; max-width: 90%; height: auto; object-fit: contain; align-self: center; margin-bottom: 4px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: 1px; text-align: center; color: var(--text); }
.auth-sub { font-size: 12px; color: var(--muted); text-align: center; margin-top: -6px; margin-bottom: 8px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.auth-card input {
  background: var(--raised); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; color: var(--text); outline: none;
}
.auth-card input:focus { border-color: var(--gold); }
.auth-btn {
  margin-top: 8px; background: #f6b10a; color: #17130a; border: 1px solid #f6b10a;
  border-radius: 8px; padding: 11px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.auth-btn:disabled { opacity: 0.55; cursor: default; }
.auth-error {
  font-size: 13px; color: #ffb4ae; background: rgba(229,83,75,0.12);
  border: 1px solid rgba(229,83,75,0.4); border-radius: 8px; padding: 9px 12px;
}
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.user-chip .uc-name { color: var(--text); font-weight: 600; }
.user-chip .uc-logout {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.user-chip .uc-logout:hover { color: var(--text); border-color: var(--gold); }

/* ---------------- dashboard highlight row: COIN Impact (1/3) + Brief (2/3) ---------------- */
.dash-row { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; align-items: stretch; }
.dash-row .section { margin: 0; display: flex; flex-direction: column; }
.dash-row .section > .card { flex: 1; }
.impact-card { display: flex; flex-direction: column; gap: 20px; padding: 24px; }
.imp-top { display: flex; align-items: baseline; gap: 8px; }
.imp-v { font-size: 30px; font-weight: 700; color: var(--gold); line-height: 1; }
.imp-badge { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--degraded); }
.imp-l { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 6px; }
.imp-note { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
@media (max-width: 1000px) { .dash-row { grid-template-columns: 1fr; } }

/* ---------------- Daily Executive Brief ---------------- */
.brief-card { display: flex; flex-direction: column; padding: 16px 22px 20px; }
.brief-item { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.brief-item:last-of-type { border-bottom: none; }
.brief-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.brief-item.p1 .brief-dot { background: var(--gold); }
.brief-item.p2 .brief-dot { background: var(--degraded); }
.brief-item.p3 .brief-dot { background: var(--healthy); }
.brief-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.brief-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.brief-item .btn { flex: none; align-self: center; }
.brief-foot { font-size: 11px; color: var(--muted); margin-top: 12px; font-style: italic; }
