:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1a1d24;
  --muted: #707888;
  --line: #e4e7ec;
  --accent: #2f3aa3;
  --accent-soft: #eef0fb;
  --ok: #1a8f5e;
  --ok-soft: #e6f5ee;
  --warn: #b26b00;
  --warn-soft: #fbf1df;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5;
}
h1, h2, h3 { margin: 0 0 .5em; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.muted { color: var(--muted); }
.error { color: #b42318; }
.ok { color: #067647; font-size: 13px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--panel); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 360px; }
.login-card label { display: block; margin: 14px 0; font-weight: 600; font-size: 13px; }
.login-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-weight: 400; }
.login-card button { width: 100%; margin-top: 8px; }
.login-sub { color: var(--muted); margin-top: 4px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.login-foot { margin-top: 12px; text-align: center; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand-mark { background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 7px; font-size: 14px; }

button { background: var(--accent); color: #fff; border: 0; padding: 10px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; }
button:hover { filter: brightness(1.06); }
.link-btn { background: none; color: var(--muted); padding: 0; font-weight: 500; }
.link-btn:hover { color: var(--ink); filter: none; text-decoration: underline; }

/* App shell */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { padding: 4px 8px 16px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { background: none; color: var(--ink); text-align: left; padding: 9px 12px; border-radius: 9px; font-weight: 500; }
.nav-item:hover { background: var(--bg); filter: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; }
.sidebar-foot #who { margin-bottom: 8px; }

.main { padding: 24px 32px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { font-size: 22px; letter-spacing: -.02em; }
#client-badge { color: var(--muted); font-weight: 600; }

/* Badges */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; vertical-align: middle; }
.badge-live { background: var(--ok-soft); color: var(--ok); }
.badge-mock { background: var(--warn-soft); color: var(--warn); }
.surface-src { color: var(--muted); margin: 0 0 16px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-n { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.card-l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.trend { margin-top: 8px; font-size: 12px; font-weight: 700; }
.trend.up { color: var(--ok); } .trend.down { color: #b42318; }
.chan { margin: 22px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Tables */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.grid th, .grid td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.grid th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.grid tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; }
.tag { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.status { font-size: 12px; font-weight: 600; color: var(--muted); }
.status-ok { color: var(--ok); }
.status-warn { color: #b54708; }
.client-logo { height: 22px; width: auto; vertical-align: middle; margin-right: 8px; border-radius: 4px; }

/* Forms */
.inline-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form.col { flex-direction: column; margin-top: 12px; }
.inline-form input { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.inline-form select, .inline-form textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; }
.inline-form .form-row { display: flex; gap: 8px; }
.inline-form .form-row select { flex: 1; }
.svc-desc { margin-top: 4px; font-size: 12px; color: var(--muted); }
.svc-desc summary { cursor: pointer; color: var(--accent); }
.prio { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; text-transform: capitalize; }
.prio-urgent { background: #fee4e2; color: #b42318; }
.prio-high { background: #fef0c7; color: #b54708; }
.prio-normal { background: var(--accent-soft); color: var(--accent); }
.prio-low { background: #eceef1; color: var(--muted); }

/* Mail */
.two-col { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.senders { list-style: none; padding: 0; margin: 0 0 8px; }
.senders li { padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* Reports */
.report-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.report-tab { background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.report-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.report-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); max-width: 760px; }
.report-body h2 { font-size: 20px; } .report-body h3 { font-size: 15px; margin-top: 18px; }
.report-body blockquote { border-left: 3px solid var(--warn); background: var(--warn-soft); margin: 0 0 14px; padding: 10px 14px; border-radius: 0 8px 8px 0; color: #6b4e1a; }

.note { color: var(--muted); margin-top: 18px; max-width: 640px; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .two-col { grid-template-columns: 1fr; }
}
