/* Squirl Control. Brand: navy #0b1b33, squirrel orange #e8731c, headset sky #4fb3e8, cream #fde6c6.
   Light and dark themes via prefers-color-scheme. */
:root {
  --navy: #0b1b33;
  --navy-2: #13294a;
  --orange: #e8731c;
  --orange-hover: #cf6212;
  --sky: #4fb3e8;
  --cream: #fde6c6;

  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #13202f;
  --muted: #5d6b7a;
  --line: #e2e6eb;
  --line-strong: #c9d0d8;
  --hover: rgba(11, 27, 51, 0.04);
  --accent: var(--orange);
  --on-accent: #ffffff;
  --link: #1f6fb0;
  --ok: #2f8a55;    --ok-bg: #e5f4ea;
  --warn: #a86200;  --warn-bg: #fff1d6;
  --bad: #c0352b;   --bad-bg: #fde8e6;
  --info-bg: #e6f3fb;
  --note-bg: #fff8e8;
  --radius: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a121e;
    --card: #111c2c;
    --text: #e6ebf1;
    --muted: #94a3b4;
    --line: #22324a;
    --line-strong: #33465f;
    --hover: rgba(255, 255, 255, 0.05);
    --link: #7cc4ef;
    --ok: #6fd39a;    --ok-bg: #12301f;
    --warn: #f2b453;  --warn-bg: #3a2a0c;
    --bad: #ff7b70;   --bad-bg: #3d1614;
    --info-bg: #0f2a40;
    --note-bg: #2a2210;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 8px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 2px 5px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; margin: 0; }
.icon { flex: none; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* ---- Shell: navy rail + content ---- */
.shell { display: flex; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; width: 232px; flex: none; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
  background: var(--navy); color: #dbe5f0;
}
.rail a, .rail-btn {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px;
  color: #c9d6e4; font: inherit; font-weight: 500; text-decoration: none; background: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.rail a:hover, .rail-btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.rail a.on { background: rgba(232, 115, 28, 0.18); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
.rail .brand { padding: 6px 8px 16px; gap: 10px; color: #fff; }
.rail .brand:hover { background: none; }
.rail .brand span { display: flex; flex-direction: column; font-weight: 800; font-size: 17px; line-height: 1.1; letter-spacing: -0.01em; }
.rail .brand small { font-size: 11px; font-weight: 700; color: var(--sky); letter-spacing: 0.08em; }
.rail-spacer { flex: 1; }
.count { margin-left: auto; background: var(--orange); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.count.soft { background: rgba(255, 255, 255, 0.14); }
.main { flex: 1; min-width: 0; padding: 24px 32px 48px; max-width: 1240px; }
.main.solo { margin: 0 auto; }

/* ---- Page parts ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.head-side { display: flex; align-items: center; gap: 8px; }
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 620px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.card.flush > .card-title { padding: 14px 18px 0; }
.empty { padding: 28px 18px; margin: 0; text-align: center; color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.two-col.even { grid-template-columns: 1fr 1fr; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; gap: 4px; margin: 0; color: var(--text); }
.tile:hover { border-color: var(--orange); text-decoration: none; }
.tile span { color: var(--muted); font-size: 13px; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--info-bg); }
.flash.success { background: var(--ok-bg); }
.flash.error { background: var(--bad-bg); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); display: flex; flex-direction: column; }
a.stat:hover { border-color: var(--orange); text-decoration: none; }
.stat b { font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.warn { background: var(--warn-bg); border-color: transparent; }
.stat.bad { background: var(--bad-bg); border-color: transparent; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a.on { background: var(--navy); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.pager { display: flex; gap: 8px; justify-content: center; }

/* ---- Ticket list ---- */
.tlist { display: flex; flex-direction: column; }
.trow { display: flex; gap: 14px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--text); }
.tlist > .trow:first-child { border-top: 0; }
.trow:hover { background: var(--hover); text-decoration: none; }
.tnum { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); width: 82px; flex: none; }
.tmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tsubject { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmeta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tside { display: flex; align-items: center; gap: 10px; flex: none; }
.tassignee { font-size: 13px; color: var(--muted); width: 120px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--hover); border: 1px solid var(--line); white-space: nowrap; }
.pill.big { font-size: 14px; padding: 4px 12px; }
.pill.soft { border-color: transparent; }
.clock { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--ok-bg); color: var(--ok); }
.clock.met { background: transparent; color: var(--muted); font-weight: 500; }
.clock.warn { background: var(--warn-bg); color: var(--warn); }
.clock.urgent, .clock.overdue { background: var(--bad-bg); color: var(--bad); }
.tag-private { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); vertical-align: middle; }

/* ---- Ticket timeline ---- */
.timeline { min-width: 0; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.msg.note { background: var(--note-bg); border-color: transparent; }
.msg.reply { border-left: 3px solid var(--orange); }
.msg header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.msg header time { margin-left: auto; }
.msg .kind { font-size: 12px; font-weight: 600; color: var(--muted); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.event { font-size: 13px; color: var(--muted); margin: 0 0 12px 12px; }
.composer textarea { min-height: 90px; }
.row-end { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
label > input, label > select, label > textarea { display: block; margin-top: 4px; width: 100%; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--sky); outline: none; box-shadow: 0 0 0 3px rgba(79, 179, 232, 0.25); }
select:disabled { opacity: 0.7; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
label.check.inline { display: inline-flex; margin-right: 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.help { margin: -8px 0 12px; font-size: 13px; color: var(--muted); }
.hours { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.hours label { font-size: 12px; margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--on-accent); }
.btn.primary:hover { background: var(--orange-hover); }
.btn.wide { width: 100%; margin-top: 4px; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-size: 13px; cursor: pointer; }
form.inline { display: inline; }
.share { display: flex; gap: 6px; flex-wrap: wrap; }
.share select { flex: 1; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 18px; border-top: 1px solid var(--line); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table.compact td { padding: 5px 0; }
tr.archived, .list-item.archived summary { opacity: 0.55; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

.list-item { border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item summary { padding: 12px 18px; cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-item summary:hover { background: var(--hover); }
.item-form, .item-actions { padding: 0 18px 12px; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Org chart ---- */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 22px; padding-left: 16px; border-left: 2px solid var(--line); }
.tree li { padding: 6px 0; }
.person { display: flex; align-items: center; gap: 10px; }

/* ---- Login ---- */
.login { max-width: 420px; margin: 8vh auto 0; }
.login-logo { display: block; width: 100%; height: auto; margin-bottom: 20px; border-radius: 12px; background: #fff; padding: 6px; }
.qr { display: flex; justify-content: center; }
.qr svg { background: #fff; border-radius: 8px; }

@media (max-width: 960px) {
  .two-col, .two-col.even { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .rail { position: static; height: auto; width: 100%; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .rail a span:not(.avatar), .rail-btn span { display: none; }
  .rail .brand span { display: none; }
  .rail-spacer { display: none; }
  .rail a, .rail-btn { width: auto; padding: 8px; }
  .main { padding: 16px; }
  .tassignee, .tnum { display: none; }
  .trow { padding: 12px 16px; }
  .tside .pill { display: none; }
  .hours { grid-template-columns: repeat(4, 1fr); }
}
