@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --line: #e6e8ee; --line-strong: #d5d9e2;
  --text: #11131a; --text-2: #4a5160; --muted: #8a91a0;
  --accent: #5b5bf6; --accent-soft: #ececfe; --accent-text: #3f3fd8;
  --ok: #12a150; --ok-soft: #e3f6eb; --warn: #d97706; --warn-soft: #fdf1e2; --bad: #dc2626; --bad-soft: #fde8e8;
  --info: #0284c7; --info-soft: #e0f2fe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d12; --surface: #14161d; --surface-2: #191c25; --line: #252935; --line-strong: #323746;
    --text: #eceef3; --text-2: #b4bac7; --muted: #7c8394;
    --accent: #7c7cff; --accent-soft: #23234a; --accent-text: #a5a5ff;
    --ok: #34d399; --ok-soft: #0f2c22; --warn: #fbbf24; --warn-soft: #33270d; --bad: #f87171; --bad-soft: #3a1717;
    --info: #38bdf8; --info-soft: #0c2a3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0d12; --surface: #14161d; --surface-2: #191c25; --line: #252935; --line-strong: #323746;
  --text: #eceef3; --text-2: #b4bac7; --muted: #7c8394;
  --accent: #7c7cff; --accent-soft: #23234a; --accent-text: #a5a5ff;
  --ok: #34d399; --ok-soft: #0f2c22; --warn: #fbbf24; --warn-soft: #33270d; --bad: #f87171; --bad-soft: #3a1717;
  --info: #38bdf8; --info-soft: #0c2a3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #a855f7); display: grid; place-items: center; color: #fff; font-weight: 700; }
.brand b { display: block; font-size: 14px; } .brand span { font-size: 12px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); cursor: pointer; border: 0; background: none; font: inherit; text-align: left; width: 100%; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item .count { margin-left: auto; background: var(--warn); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 12px; color: var(--muted); padding: 10px; }
.content { padding: 28px 32px 60px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: grid; gap: 14px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.card-body { padding: 16px 18px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.attention .value { color: var(--warn); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Devices */
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.device { padding: 14px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.device:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.phone { position: relative; border-radius: 22px; padding: 6px; background: #0b0c10; box-shadow: inset 0 0 0 1px #2a2d36; margin-bottom: 12px; }
.phone img, .phone .ph { width: 100%; aspect-ratio: 1080 / 2340; object-fit: cover; border-radius: 17px; display: block; background: #1b1d24; }
.phone .ph { display: grid; place-items: center; color: #6b7280; font-size: 12px; }
.device .name { font-weight: 600; }
.device .meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 2px; gap: 6px; }

/* Inbox */
.inbox-item { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 18px; flex: none; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Runs */
.runs { display: grid; gap: 12px; }
.run { padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; cursor: pointer; }
.run:hover { border-color: var(--line-strong); }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); grid-column: 1 / -1; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #a855f7); border-radius: 99px; }

/* Timeline */
.phase-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.phase-title .line { flex: 1; height: 1px; background: var(--line); }
.day-block { margin-bottom: 14px; }
.day-label { font-weight: 600; font-size: 13px; margin: 0 0 8px 2px; display: flex; gap: 8px; align-items: center; }
.step { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .ico { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.step .t { flex: 1; min-width: 0; }
.step .t .sub { font-size: 12px; color: var(--muted); }
.step.current { background: var(--accent-soft); }
.step.is-done .t > div:first-child { color: var(--muted); }

/* Flow editor */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.flow-item { padding: 12px 14px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.flow-item:hover { background: var(--surface-2); }
.flow-item.active { background: var(--accent-soft); border-color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tab { padding: 12px 12px; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.explain { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px 16px; color: var(--text-2); font-size: 13px; }
.explain b { color: var(--text); }
.day-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: var(--surface); }
.day-card > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 12px 12px 0 0; }
.blk { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.blk:last-of-type { border-bottom: 0; }
.blk .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 16px; }
.blk .body { flex: 1; min-width: 0; }
.blk .sum { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.blk .tools { display: flex; gap: 2px; }
.blk .edit { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.add-row { padding: 10px 14px; display: flex; gap: 8px; }

/* Forms */
label.f { display: grid; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
input, select, textarea { font: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.range-row { display: grid; grid-template-columns: 1fr 60px; gap: 10px; align-items: center; }
.range-row input[type="range"] { padding: 0; border: 0; accent-color: var(--accent); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

/* Modal / Drawer */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .mbody { padding: 18px 20px; display: grid; gap: 14px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.steps-ind { display: flex; gap: 6px; } .steps-ind span { width: 26px; height: 4px; border-radius: 9px; background: var(--line-strong); } .steps-ind span.on { background: var(--accent); }
.price { font-size: 26px; font-weight: 700; }
.choice { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice label { border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.choice input { display: none; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

#toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; opacity: 0; transform: translateY(8px); transition: all .2s; max-width: 440px; white-space: pre-wrap; z-index: 80; font-size: 13px; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
  .brand, .sidebar .spacer, .sidebar .foot { display: none; }
  .nav-item { width: auto; }
  .content { padding: 18px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
