/* ==========================================================================
   AutoTicket - styles
   Laid out like the Address Book (tickets on the left, the chosen ticket on
   the right; one pane at a time on a phone), in mltech's colours:
   blue #0053A3 with orange #EC6E13 highlights. Light and dark themes.
   ========================================================================== */

:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #edf1f7;
  --border: #e0e6ef;
  --border-strong: #c9d3e1;
  --text: #0f1b2d;
  --text-2: #334155;
  --muted: #64748b;
  --brand: #0053A3;
  --brand-hover: #00427f;
  --brand-soft: #e8f1fb;
  --brand-text: #00478c;
  --orange: #EC6E13;
  --orange-soft: #fdf0e6;
  --hl: #fff4c2;
  --danger: #c4320a;
  --danger-soft: #fdeee8;
  --ok: #0f7b4f;
  --ok-soft: #e6f6ee;
  --warn: #a15c00;
  --warn-soft: #fff4e0;
  --focus: rgba(0, 83, 163, 0.32);
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.05);
  --shadow: 0 1px 3px rgba(15, 27, 45, 0.08), 0 1px 2px rgba(15, 27, 45, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(15, 27, 45, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1018; --surface: #121924; --surface-2: #161e2b; --surface-3: #1c2636;
    --border: #243045; --border-strong: #33415a; --text: #e6ebf2; --text-2: #c2cad6; --muted: #8692a6;
    --brand: #4c9be8; --brand-hover: #7ab4ee; --brand-soft: #12243b; --brand-text: #8cc0f2;
    --orange: #f28a3d; --orange-soft: #33200f; --hl: #3b3413;
    --danger: #f97066; --danger-soft: #3a1a17; --ok: #34d399; --ok-soft: #10291f; --warn: #f5b454; --warn-soft: #33270f;
    --focus: rgba(76, 155, 232, 0.45); --shadow-sm: none; --shadow: 0 1px 3px rgba(0,0,0,.45); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1018; --surface: #121924; --surface-2: #161e2b; --surface-3: #1c2636;
  --border: #243045; --border-strong: #33415a; --text: #e6ebf2; --text-2: #c2cad6; --muted: #8692a6;
  --brand: #4c9be8; --brand-hover: #7ab4ee; --brand-soft: #12243b; --brand-text: #8cc0f2;
  --orange: #f28a3d; --orange-soft: #33200f; --hl: #3b3413;
  --danger: #f97066; --danger-soft: #3a1a17; --ok: #34d399; --ok-soft: #10291f; --warn: #f5b454; --warn-soft: #33270f;
  --focus: rgba(76, 155, 232, 0.45); --shadow-sm: none; --shadow: 0 1px 3px rgba(0,0,0,.45); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.75);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { display: block; border-radius: 8px; }
.brand b { color: var(--brand); font-weight: 800; }
.brand-lg { font-size: 22px; }
.mltech-logo { display: inline-flex; align-items: center; padding-left: 14px; margin-left: 4px; border-left: 1px solid var(--border); }
.mltech-logo img { height: 46px; width: auto; display: block; }
/* The logo is blue and grey on transparent: in dark mode it sits on a small white plate. */
:root[data-theme="dark"] .mltech-logo img, :root[data-theme="dark"] .login-mobile-brand > img { background: #fff; border-radius: 7px; padding: 3px 6px; box-sizing: content-box; height: 40px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mltech-logo img, :root:not([data-theme="light"]) .login-mobile-brand > img { background: #fff; border-radius: 7px; padding: 3px 6px; box-sizing: content-box; height: 40px; } }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-orange:hover { filter: brightness(.94); background: var(--orange); }
:root[data-theme="dark"] .btn-primary { color: #06101c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #06101c; } }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); text-decoration: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 17px; height: 17px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; }
.field-label .opt { font-weight: 400; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input-lg { height: 46px; font-size: 15px; }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

.notice { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin: 12px 0; }
.notice-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.notice-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }

/* Segmented buttons (priority, theme) */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--brand-soft); color: var(--brand-text); }

/* Tick boxes */
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 14px; background: var(--surface); }
.check:hover { background: var(--surface-2); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.check:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }

/* Switches */
.switch-line { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; font-size: 14px; line-height: 1.5; margin-top: 12px; }
.switch-line .muted { font-size: 13px; }
.switch-line input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; margin-top: 1px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch-line input:checked + .switch { background: var(--brand); }
.switch-line input:checked + .switch::after { transform: translateX(18px); }
.switch-line input:focus-visible + .switch { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Spell-check (proofread) status under each box ---------- */

.pf-wrap { position: relative; }
.pf-status { display: flex; align-items: center; gap: 6px; min-height: 0; font-size: 12px; color: var(--muted); margin-top: 4px; }
.pf-status:empty { display: none; }
.pf-status .spinner { width: 12px; height: 12px; border-width: 2px; }
.pf-status.ok { color: var(--ok); }
.pf-status.fixed { color: var(--brand-text); }
.pf-status.err { color: var(--warn); }
.pf-status button { border: 0; background: none; padding: 0; font-weight: 700; font-size: 12px; color: var(--orange); text-decoration: underline; }
.pf-busy { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 7%, transparent), transparent); background-size: 200% 100%; animation: pfshine 1.2s linear infinite; }
.pf-flash { animation: pfflash 1.4s ease-out; }
@keyframes pfshine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pfflash { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 45%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Login page ---------- */

.login-body { background: var(--surface); min-height: 100vh; }
.login-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-hero {
  position: relative; overflow: hidden; color: #dbe9f8;
  background:
    radial-gradient(1100px 600px at -10% -20%, rgba(76, 155, 232, .55), transparent 60%),
    radial-gradient(800px 480px at 115% 115%, rgba(236, 110, 19, .38), transparent 60%),
    linear-gradient(150deg, #001d3d 0%, #003a75 55%, #0053A3 100%);
}
.login-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .16; background-image: radial-gradient(rgba(255,255,255,.55) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); }
.login-hero-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 44px 56px; max-width: 640px; }
.hero-logo { background: #fff; border-radius: 14px; padding: 12px 18px; display: inline-flex; align-self: flex-start; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.hero-logo img { height: 78px; display: block; }
.hero-copy { margin-top: auto; }
.hero-copy .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #ffd1ad; margin-bottom: 14px; }
.hero-copy .kicker::before { content: ""; width: 22px; height: 3px; border-radius: 3px; background: var(--orange); }
.hero-copy h1 { color: #fff; font-size: clamp(30px, 3.4vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 700; }
.hero-copy p { font-size: 17px; color: #bcd6f2; margin: 0; max-width: 470px; }
.hero-points { list-style: none; padding: 0; margin: 40px 0 auto; display: grid; gap: 18px; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; font-size: 14.5px; color: #bcd6f2; line-height: 1.45; }
.hero-points strong { color: #fff; font-weight: 600; }
.hero-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff; flex: none; }
.hero-foot { font-size: 13px; color: #8fb6e0; margin: 32px 0 0; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-form { width: 100%; max-width: 380px; }
.login-mobile-brand { display: none; margin-bottom: 28px; align-items: center; justify-content: space-between; width: 100%; }
.login-title { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-form .btn-block { margin-top: 24px; }
.login-foot { color: var(--muted); font-size: 13px; text-align: center; margin: 16px 0 0; }
.login-version { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 0; opacity: .75; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover, .pw-toggle.on { color: var(--brand); }
@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-mobile-brand { display: flex; }
  .login-panel { align-items: flex-start; padding-top: 10vh; }
}

/* ---------- Top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--brand) 0 78%, var(--orange) 78% 100%); }
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; gap: 20px; padding: 0 20px; }
.search { position: relative; flex: 1; max-width: 600px; margin: 0 auto; }
.search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { width: 100%; height: 42px; padding: 0 44px 0 40px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-3); color: var(--text); font-size: 15px; transition: background .15s, border-color .15s, box-shadow .15s; }
.search input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 11px/1 "Inter", sans-serif; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 5px; padding: 4px 6px; background: var(--surface); }
.search input:focus + .search-kbd { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.banner { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 9px 16px; font-size: 14px; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; }
.banner a { color: inherit; font-weight: 700; }

/* ---------- Two-pane layout ---------- */

.layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); }
body:has(.banner:not([hidden])) .layout { height: calc(100vh - var(--topbar-h) - 40px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.views { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.views button { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; }
.views button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.views button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .views button.on { color: #06101c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .views button.on { color: #06101c; } }
.views button .n { font-weight: 600; font-size: 11.5px; opacity: .75; }
.views button.overdue-view .n { color: var(--danger); opacity: 1; }
.views button.on .n { color: inherit; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.count { font-weight: 600; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 2px 9px; letter-spacing: 0; }
.ticket-list { overflow-y: auto; padding: 0 10px 20px; flex: 1; }
.detail { overflow-y: auto; min-width: 0; outline: none; }
.list-empty { padding: 30px 14px; text-align: center; color: var(--muted); font-size: 14px; }

.t-item { display: block; padding: 11px 12px 12px; border-radius: 10px; text-decoration: none; color: inherit; border: 1px solid transparent; margin-bottom: 2px; position: relative; }
.t-item:hover { background: var(--surface-2); }
.t-item.active { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.t-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--brand); }
.t-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.t-ref { font-weight: 700; color: var(--brand-text); letter-spacing: .01em; }
.t-age { margin-left: auto; white-space: nowrap; }
.t-title { font-weight: 600; font-size: 14.5px; margin: 2px 0 3px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.t-meta .sep { opacity: .5; }

/* Status & priority pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { background: var(--brand-soft); color: var(--brand-text); }
.st-in-progress { background: color-mix(in srgb, #7c3aed 13%, var(--surface)); color: color-mix(in srgb, #6d28d9 80%, var(--text)); }
.st-waiting-on-client { background: var(--orange-soft); color: color-mix(in srgb, var(--orange) 80%, var(--text)); }
.st-resolved { background: var(--ok-soft); color: var(--ok); }
.st-closed { background: var(--surface-3); color: var(--muted); }
.pr { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.pr svg { width: 13px; height: 13px; stroke-width: 2.4; }
.pr-urgent { color: var(--danger); }
.pr-high { color: var(--orange); }
.pr-normal { color: var(--muted); }
.pr-low { color: var(--muted); opacity: .8; }
.overdue-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--danger); background: var(--danger-soft); padding: 1px 7px; border-radius: 999px; }
.overdue-tag svg { width: 12px; height: 12px; stroke-width: 2.4; }

/* Avatars */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 38px; height: 38px; font-size: 13.5px; }
.av0 { background: linear-gradient(135deg, #1a6cc0, #003d7a); }
.av1 { background: linear-gradient(135deg, #f28a3d, #c25509); }
.av2 { background: linear-gradient(135deg, #10b981, #047857); }
.av3 { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.av4 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av5 { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.av6 { background: linear-gradient(135deg, #64748b, #334155); }
.av7 { background: linear-gradient(135deg, #f43f5e, #be123c); }
.people-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 13.5px; font-weight: 500; }
.person-chip .avatar { width: 24px; height: 24px; font-size: 10px; }

/* ---------- Detail pane ---------- */

.detail-inner { max-width: 1060px; margin: 0 auto; padding: 26px 32px 64px; }
.back-link { display: none; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.t-header { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.t-header-main { min-width: 0; flex: 1; }
.t-header .t-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.t-header .t-kicker .t-ref { font-size: 13px; }
.t-header h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; line-height: 1.25; }
.t-header .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.t-header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex: none; }

/* status steps */
.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 0 0 20px; }
.step { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 10px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; text-align: left; transition: border-color .15s, background .15s; }
.step:hover { border-color: var(--border-strong); background: var(--surface-2); }
.step .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.step .dot svg { width: 12px; height: 12px; stroke-width: 3; }
.step.done { color: var(--text-2); }
.step.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.current { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.step.current .dot { border-color: var(--brand); background: var(--surface); }
.step.current .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .01em; display: flex; gap: 8px; align-items: center; }
.card-head h2 svg { color: var(--brand); width: 18px; height: 18px; }
.card-head h2 .count { margin-left: 2px; }
.card-body { padding: 16px 18px; }
.card-text { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.empty-line { color: var(--muted); font-size: 14px; }
.prose { white-space: pre-wrap; font-size: 14.5px; color: var(--text-2); line-height: 1.65; overflow-wrap: anywhere; }
.resolution-card { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.resolution-card .card-head { background: color-mix(in srgb, var(--ok) 6%, var(--surface)); border-radius: var(--radius) var(--radius) 0 0; }
.resolution-card .card-head h2 svg { color: var(--ok); }

dl.facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.facts a { color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--border-strong); }
dl.facts a:hover { color: var(--brand); border-color: var(--brand); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 6px 18px 4px; }
.tl { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 12px 0; position: relative; }
.tl + .tl { border-top: 1px solid var(--border); }
.tl-ico { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-2); }
.tl-ico svg { width: 17px; height: 17px; }
.tl.k-call .tl-ico { background: color-mix(in srgb, #10b981 15%, var(--surface)); color: var(--ok); }
.tl.k-email_in .tl-ico { background: var(--orange-soft); color: var(--orange); }
.tl.k-email_out .tl-ico { background: var(--brand-soft); color: var(--brand); }
.tl.k-meeting .tl-ico { background: color-mix(in srgb, #8b5cf6 15%, var(--surface)); color: #7c3aed; }
.tl.k-status, .tl.k-system { padding: 7px 0; }
.tl.k-status .tl-ico, .tl.k-system .tl-ico { background: transparent; width: 34px; height: 22px; color: var(--muted); }
.tl.k-status .tl-body, .tl.k-system .tl-body { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.tl.k-status .tl-text, .tl.k-system .tl-text { white-space: pre-line; }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 13px; color: var(--muted); }
.tl-head strong { color: var(--text); font-weight: 600; font-size: 14px; }
.tl-kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tl-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.tl:hover .tl-actions, .tl:focus-within .tl-actions { opacity: 1; }
@media (hover: none) { .tl-actions { opacity: 1; } }
.tl-text { white-space: pre-wrap; font-size: 14.5px; color: var(--text-2); margin-top: 3px; line-height: 1.6; overflow-wrap: anywhere; }
.tl-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.composer { border-top: 1px solid var(--border); padding: 14px 18px 16px; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.composer-top { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.composer-top button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.composer-top button svg { width: 15px; height: 15px; }
.composer-top button.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand-text); }
.composer .textarea { min-height: 84px; background: var(--surface); }
.composer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.composer-bar .spacer { flex: 1; }
.composer-bar .select { width: auto; height: 34px; font-size: 13.5px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Files */
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 10px 6px 6px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); text-decoration: none; color: var(--text); font-size: 13px; }
.file-chip:hover { border-color: var(--brand); }
.file-chip .ext { flex: none; width: 30px; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 9.5px; font-weight: 800; letter-spacing: .02em; color: #fff; background: var(--brand); text-transform: uppercase; }
.file-chip .ext.pdf { background: #d1352b; }
.file-chip .ext.img { background: #0f9d76; }
.file-chip .ext.cad { background: var(--orange); }
.file-chip .ext.doc { background: #2b5fb4; }
.file-chip .ext.zip { background: #64748b; }
.file-chip .fn { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.file-chip .sz { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-chip button { border: 0; background: none; color: var(--muted); padding: 0 0 0 2px; display: inline-flex; }
.file-chip button:hover { color: var(--danger); }
.file-chip button svg { width: 15px; height: 15px; }
.files { display: grid; gap: 8px; padding: 14px 18px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.file-row .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--border); background: var(--surface-3); }
.file-row .file-chip { border: 0; padding: 0; background: none; flex: 1; min-width: 0; }
.file-row .meta { font-size: 12px; color: var(--muted); }
.file-row .acts { display: flex; gap: 2px; flex: none; }
.drop { border: 1.5px dashed var(--border-strong); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 13px; padding: 16px 10px; cursor: pointer; background: transparent; text-align: center; width: 100%; }
.drop svg { width: 22px; height: 22px; }
.drop:hover, .drop.over { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- Dashboard (no ticket chosen) ---------- */

.dash { max-width: 1060px; margin: 0 auto; padding: 30px 32px 64px; }
.dash-hello { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.dash-hello h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.dash-hello p { margin: 4px 0 0; color: var(--muted); }
.dash-hello .btn { margin-left: auto; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.tile.t-orange::after { background: var(--orange); }
.tile.t-red::after { background: var(--danger); }
.tile.t-green::after { background: var(--ok); }
.tile .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile b { display: block; font-size: 30px; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; }
.tile .note { font-size: 12.5px; color: var(--muted); }
.dash-list .t-item { border: 1px solid var(--border); background: var(--surface); margin-bottom: 8px; }

/* ---------- Settings ---------- */

.settings h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 6px; }
.settings .lead { color: var(--muted); margin: 0 0 22px; }
.settings .card + .card { margin-top: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.status-line { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 0; font-size: 13.5px; }
.status-line:empty { margin: 0; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--danger); }
.status-line svg { width: 16px; height: 16px; margin-top: 2px; stroke-width: 2.4; }
.key-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.key-pill.on { background: var(--ok-soft); color: var(--ok); }
.key-pill.off { background: var(--warn-soft); color: var(--warn); }
.person-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: 0; padding-bottom: 0; }
.person-row:first-child { padding-top: 0; }
.person-row .body { flex: 1; min-width: 0; }
.person-row .name { font-weight: 600; font-size: 14.5px; }
.person-row .meta { color: var(--muted); font-size: 12.5px; }
.tag { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }
.tag.admin { background: var(--brand-soft); color: var(--brand-text); }
.tag.off { background: var(--danger-soft); color: var(--danger); }
.device { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.device:last-child { border-bottom: 0; }
.device .meta { color: var(--muted); font-size: 12.5px; }
.remind-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.remind-grid .input { text-align: right; }

/* ---------- Modal ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(6, 14, 26, .5); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 580px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease-out; }
.modal.modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.modal-head h3 .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }
.modal-head h3 .ico svg { width: 18px; height: 18px; }
.modal-body { padding: 0 22px 8px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 18px 22px 20px; border-top: 1px solid var(--border); margin-top: 14px; }
.modal-foot .spacer { flex: 1; }
.section-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.section-label::before { content: ""; width: 14px; height: 3px; border-radius: 3px; background: var(--orange); }
.section-label:first-child { border-top: 0; padding-top: 4px; margin-top: 4px; }

/* ---------- Toasts & loading ---------- */

.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; }
.toast { background: #0f1b2d; color: #f9fafb; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.toast.err { background: #b42318; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ---------- Smaller screens ---------- */

@media (max-width: 1200px) {
  .grid-main { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .mltech-logo { display: none; }
}
@media (max-width: 820px) {
  :root { --topbar-h: 112px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search-kbd { display: none; }
  .topbar-actions { margin-left: auto; }
  .btn-new span { display: none; }
  .btn-new { width: 38px; padding: 0; }
  .layout { grid-template-columns: 1fr; height: auto; }
  body:has(.banner:not([hidden])) .layout { height: auto; }
  .sidebar { border-right: 0; background: var(--bg); }
  .ticket-list { overflow: visible; padding: 0 10px 40px; }
  .t-item { background: var(--surface); border-color: var(--border); margin-bottom: 8px; }
  .detail { overflow: visible; }
  .layout.show-detail .sidebar { display: none; }
  .layout:not(.show-detail) .detail { display: none; }
  .back-link { display: inline-flex; }
  .detail-inner, .dash { padding: 16px 16px 48px; }
  .t-header { flex-wrap: wrap; }
  .t-header h1 { font-size: 22px; }
  .t-header-actions { width: 100%; justify-content: flex-start; }
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .step { flex-direction: column; font-size: 11px; padding: 7px 4px; text-align: center; gap: 4px; }
  .grid-2, .row3 { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 94vh; overflow-y: auto; }
  .remind-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dl.facts { grid-template-columns: 105px minmax(0, 1fr); }
}
@media (max-width: 460px) {
  .row2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
}
