/* CC Controller web client – Windows 11 inspired, light/dark from the system. */
:root {
  --bg: #f3f3f3; --layer: #fafafa; --card: #ffffff; --card-hover: #f9f9f9; --alt: rgba(0,0,0,.04);
  --border: rgba(0,0,0,.08); --strong: rgba(0,0,0,.16);
  --text: rgba(0,0,0,.9); --muted: rgba(0,0,0,.62); --faint: rgba(0,0,0,.45);
  --accent: #005fb8; --accent-text: #fff; --accent-soft: rgba(0,95,184,.12);
  --ok: #0f7b0f; --ok-soft: rgba(15,123,15,.12); --warn: #9d5d00; --warn-soft: rgba(247,185,0,.18);
  --danger: #c42b1c; --danger-soft: rgba(196,43,28,.1);
  --radius: 8px; --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
  --mono: "Cascadia Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202020; --layer: #272727; --card: #2d2d2d; --card-hover: #333; --alt: rgba(255,255,255,.05);
    --border: rgba(255,255,255,.08); --strong: rgba(255,255,255,.16);
    --text: #fff; --muted: rgba(255,255,255,.75); --faint: rgba(255,255,255,.5);
    --accent: #60cdff; --accent-text: #000; --accent-soft: rgba(96,205,255,.16);
    --ok: #6ccb5f; --ok-soft: rgba(108,203,95,.15); --warn: #fce100; --warn-soft: rgba(252,225,0,.14);
    --danger: #ff99a4; --danger-soft: rgba(255,153,164,.14);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; height: 100vh; height: 100dvh; }
.side { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.logo { width: 32px; height: 32px; display: block; flex: none; }
.brand b { display: block; font-size: 14px; } .brand small { color: var(--faint); font-size: 11px; }
.nav { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 4px; color: var(--text); text-decoration: none; position: relative; }
.nav:hover { background: var(--alt); }
.nav.active { background: var(--alt); }
.nav.active::before { content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 16px; margin-top: -8px; border-radius: 2px; background: var(--accent); }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side .spacer { flex: 1; }
.me { display: flex; gap: 10px; align-items: center; padding: 8px; font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-weight: 600; }
.main { background: var(--layer); border-left: 1px solid var(--border); border-top-left-radius: 8px; overflow-y: auto; }
.page { max-width: 1100px; padding: 28px 32px 48px; }
h1 { font-size: 28px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.section { font-size: 12px; font-weight: 600; color: var(--muted); margin: 22px 2px 8px; }

/* components */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.tile { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.tile:hover { background: var(--card-hover); }
.badge { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 18px; flex: none; }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.ok { background: var(--ok-soft); color: var(--ok); }
.tile .num { font-size: 24px; font-weight: 600; line-height: 1.1; }
.btn { border: 1px solid var(--border); background: var(--card); padding: 6px 14px; border-radius: 4px; cursor: pointer; min-height: 32px; }
.btn:hover { background: var(--card-hover); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--alt); }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], textarea, select {
  width: 100%; background: var(--card); border: 1px solid var(--border); border-bottom-color: var(--strong); border-radius: 4px; padding: 7px 10px; min-height: 34px;
}
input:focus, textarea:focus, select:focus { outline: none; border-bottom: 2px solid var(--accent); }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.list { display: flex; flex-direction: column; gap: 2px; }
.item { display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 4px; cursor: pointer; position: relative; }
.item:hover { background: var(--alt); }
.item.sel { background: var(--alt); }
.item.sel::before { content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 16px; margin-top: -8px; border-radius: 2px; background: var(--accent); }
.item .t { flex: 1; min-width: 0; }
.item .t b, .item .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t span { color: var(--faint); font-size: 12px; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--alt); color: var(--muted); white-space: nowrap; }
.chip.today { background: var(--accent-soft); color: var(--accent); } .chip.late { background: var(--danger-soft); color: var(--danger); }
.check { width: 20px; height: 20px; border: 1.5px solid var(--strong); border-radius: 50%; background: transparent; cursor: pointer; flex: none; display: grid; place-items: center; font-size: 12px; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.done .t b { text-decoration: line-through; opacity: .6; }
.split { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 20px; min-height: calc(100dvh - 140px); }
.editor-title { font-size: 24px; font-weight: 600; border: 0 !important; background: transparent !important; padding: 4px 0 !important; }
.editor-body { font-family: var(--mono); font-size: 14px; min-height: 50vh; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md pre { background: var(--alt); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md code { font-family: var(--mono); background: var(--alt); padding: 1px 4px; border-radius: 3px; }
.md blockquote { border-left: 3px solid var(--strong); margin: 6px 0; padding: 2px 12px; color: var(--muted); }
.muted { color: var(--muted); } .faint { color: var(--faint); font-size: 12px; }
.banner { padding: 10px 14px; border-radius: 6px; background: var(--warn-soft); margin-bottom: 14px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 4px; margin-top: 12px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .badge { margin: 0 auto 14px; width: 60px; height: 60px; font-size: 26px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); max-width: 760px; }
.bubble.me { align-self: flex-end; background: var(--accent-soft); }
.proposal { border-color: var(--accent); }
.composer { position: sticky; bottom: 0; background: var(--layer); padding: 12px 0 4px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); padding: 26px; }
.login .logo { width: 64px; height: 64px; margin: 0 auto 12px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--strong); border-radius: 8px; padding: 10px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10; }

/* phone: bottom tab bar */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { order: 2; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); overflow-x: auto; gap: 0; }
  .brand, .me, .side .spacer, .nav .lbl, .side hr { display: none; }
  .nav { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 10px; min-width: 60px; justify-content: center; }
  .nav .lbl-short { display: block; }
  .nav.active::before { left: 50%; top: auto; bottom: 0; width: 16px; height: 3px; margin: 0 0 0 -8px; }
  .main { border: 0; border-radius: 0; }
  .page { padding: 18px 14px 32px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .split.editing .listpane { display: none; }
  .split:not(.editing) .editpane { display: none; }
  h1 { font-size: 24px; }
}
@media (min-width: 761px) { .nav .lbl-short, .only-phone { display: none; } }

/* utilities (no inline styles: the CSP forbids them) */
.block { display: block; width: 100%; } .mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt18 { margin-top: 18px; }
.mb14 { margin-bottom: 14px; } .my12 { margin: 12px 0; } .gap { height: 10px; } .center { text-align: center; } .nowrap { flex-wrap: nowrap; }
.w170 { max-width: 170px; } .maxw640 { max-width: 640px; } .scrollx { overflow-x: auto; }
.check-label { display: flex; gap: 8px; align-items: center; color: var(--text); }
a.item { text-decoration: none; color: inherit; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; color: inherit; } a.btn.primary { color: var(--accent-text); } a.chip { text-decoration: none; }

/* dialog */
dialog.dialog { width: min(560px, calc(100vw - 32px)); color: var(--text); padding: 22px; box-shadow: 0 16px 48px rgba(0,0,0,.28); }
dialog.dialog::backdrop { background: rgba(0,0,0,.35); }
dialog.dialog select { width: auto; flex: none; }
