/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ebf4;
  --border: #e2e5ef;
  --text: #171a2c;
  --text-2: #4b5170;
  --text-3: #7c829f;
  --primary: #4f46e5;
  --primary-2: #4338ca;
  --primary-soft: #eef0ff;
  --on-primary: #ffffff;
  --success: #0f9d6b;
  --success-soft: #e3f7ef;
  --warning: #b7791f;
  --warning-soft: #fdf3dd;
  --danger: #d63d4f;
  --danger-soft: #fde8eb;
  --info: #2877d6;
  --info-soft: #e5f0fd;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 4px 16px rgba(20, 24, 50, .06);
  --shadow-lg: 0 10px 40px rgba(20, 24, 50, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020;
    --surface: #161a2e;
    --surface-2: #1d2239;
    --surface-3: #262c48;
    --border: #2b3150;
    --text: #eceefa;
    --text-2: #b4b9d6;
    --text-3: #838aac;
    --primary: #7c74ff;
    --primary-2: #948dff;
    --primary-soft: #262a52;
    --success: #3ccf95;
    --success-soft: #133a2c;
    --warning: #f0b453;
    --warning-soft: #3d3016;
    --danger: #ff6b7c;
    --danger-soft: #401c24;
    --info: #62a8ff;
    --info-soft: #172d4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.success.solid { background: var(--success); border-color: var(--success); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn.sm { padding: .35rem .7rem; font-size: 13px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; border: none; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.primary { background: var(--primary); color: var(--on-primary); }
.icon-btn.primary:hover { background: var(--primary-2); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .62rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3.8rem; }
.pw-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--text-3); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: .3rem .4rem; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: .3rem; }
.strength { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: .45rem; overflow: hidden; }
.strength > i { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert a { font-weight: 600; word-break: break-all; }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); text-transform: capitalize; }
.pill.open { background: var(--info-soft); color: var(--info); }
.pill.in_progress { background: var(--primary-soft); color: var(--primary); }
.pill.pending_approval { background: var(--warning-soft); color: var(--warning); }
.pill.approved, .pill.resolved { background: var(--success-soft); color: var(--success); }
.pill.rejected { background: var(--danger-soft); color: var(--danger); }
.pill.closed { background: var(--surface-3); color: var(--text-3); }
.pill.prio-critical { background: var(--danger-soft); color: var(--danger); }
.pill.prio-high { background: var(--warning-soft); color: var(--warning); }
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: 12px; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.badge.ai .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

/* ---------------------------------------------------------------- auth pages */
.auth-layout { min-height: 100%; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; padding: 3.5rem clamp(2rem, 5vw, 5rem); color: #fff;
  background: radial-gradient(1200px 600px at -10% -10%, #7c74ff 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #0ea5e9 0%, transparent 55%), #1e1b4b;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-hero .brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 18px; margin-bottom: 2.5rem; color: #fff; }
.auth-hero .brand img { width: 34px; height: 34px; }
.auth-hero h1 { font-size: clamp(28px, 3.4vw, 42px); letter-spacing: -.02em; margin-bottom: 1rem; }
.auth-hero p.lead { font-size: 17px; opacity: .85; max-width: 34rem; margin-bottom: 2rem; }
.feature-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; max-width: 36rem; }
.feature-list li { display: flex; gap: .6rem; align-items: flex-start; font-size: 14.5px; opacity: .95; }
.feature-list svg.icon { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: rgba(255, 255, 255, .14); }
.feature-list strong { display: block; }
.feature-list span { opacity: .75; font-size: 13px; }
.auth-panel { display: grid; place-items: center; padding: 2.5rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 22px; }
.auth-card .sub { color: var(--text-3); margin-bottom: 1.4rem; font-size: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); padding: 4px; border-radius: 11px; margin-bottom: 1.5rem; }
.seg button { border: none; background: none; padding: .55rem; border-radius: 8px; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.auth-foot { margin-top: 1.2rem; font-size: 13px; color: var(--text-3); text-align: center; }
.single-card-page { min-height: 100%; display: grid; place-items: center; padding: 2rem 1rem; }
.single-card-page .auth-card .brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--text); }
.single-card-page .auth-card .brand img { width: 30px; height: 30px; }

/* ---------------------------------------------------------------- app shell */
body.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 0 1.1rem; height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.tabs { display: flex; gap: .2rem; margin-left: 1rem; overflow-x: auto; }
.tab { border: none; background: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-2); padding: .5rem .85rem; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .7rem; position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--primary); color: #fff; flex: none; }
.avatar-btn { border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.menu { position: absolute; right: 0; top: 48px; width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; z-index: 50; }
.menu-head { padding: .6rem .7rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu-head strong { display: block; }
.menu-head span { font-size: 13px; color: var(--text-3); word-break: break-all; }
.menu button { display: flex; width: 100%; gap: .6rem; align-items: center; text-align: left; border: none; background: none; font: inherit; font-size: 14px; color: var(--text); padding: .55rem .7rem; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.banner { flex: none; display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap; padding: .55rem 1rem; font-size: 14px; background: var(--warning-soft); color: var(--warning); }
.banner .btn { color: inherit; border-color: currentColor; background: transparent; }
main { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; min-height: 0; }
.page { overflow-y: auto; padding: 1.6rem clamp(1rem, 3vw, 2.4rem); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 22px; margin: 0; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; padding: .5rem .7rem; font-size: 14px; }

/* ---------------------------------------------------------------- assistant */
.assistant { display: flex; }
.sidebar { width: 270px; flex: none; border-right: 1px solid var(--border); background: var(--surface); padding: 1rem .8rem; display: flex; flex-direction: column; min-height: 0; }
.sidebar-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 1.2rem .5rem .5rem; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-list li { display: flex; align-items: center; gap: .3rem; border-radius: 9px; }
.conv-list li button.open { flex: 1; min-width: 0; text-align: left; border: none; background: none; font: inherit; font-size: 14px; color: var(--text-2); padding: .55rem .6rem; border-radius: 9px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list li:hover { background: var(--surface-2); }
.conv-list li.active { background: var(--primary-soft); }
.conv-list li.active button.open { color: var(--primary); font-weight: 600; }
.conv-list li .del { opacity: 0; width: 30px; height: 30px; }
.conv-list li:hover .del { opacity: 1; }
.conv-list .empty { color: var(--text-3); font-size: 13px; padding: .5rem; }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 1.6rem clamp(1rem, 4vw, 3rem) 1rem; scroll-behavior: smooth; }
.messages-inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; }
.welcome { max-width: 820px; margin: 3vh auto 0; text-align: center; }
.welcome .hello-orb { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%; background: conic-gradient(from 180deg, #7c74ff, #0ea5e9, #22c55e, #7c74ff); box-shadow: 0 8px 30px rgba(79, 70, 229, .35); display: grid; place-items: center; color: #fff; }
.welcome .hello-orb svg.icon { width: 30px; height: 30px; }
.welcome h1 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; }
.welcome p { color: var(--text-2); margin-bottom: 1.6rem; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; text-align: left; }
.quick { display: flex; gap: .75rem; align-items: flex-start; padding: .95rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.quick:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.quick svg.icon { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.quick strong { display: block; font-size: 14.5px; }
.quick span { display: block; font-size: 13px; color: var(--text-3); line-height: 1.35; }

.msg { display: flex; gap: .7rem; align-items: flex-start; animation: rise .2s ease-out; }
.msg .avatar { width: 32px; height: 32px; font-size: 13px; }
.msg.bot .avatar { background: conic-gradient(from 180deg, #7c74ff, #0ea5e9, #22c55e, #7c74ff); }
.msg.bot .avatar svg.icon { width: 17px; height: 17px; color: #fff; }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--surface-3); color: var(--text-2); }
.msg-body { min-width: 0; max-width: min(620px, 85%); display: flex; flex-direction: column; gap: .5rem; }
.msg.user .msg-body { align-items: flex-end; }
.bubble { padding: .7rem .95rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.msg.bot .bubble { border-top-left-radius: 5px; }
.msg.user .bubble { background: var(--primary); color: var(--on-primary); border-color: var(--primary); border-top-right-radius: 5px; box-shadow: none; white-space: pre-wrap; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .3rem 0 .6rem; padding-left: 1.3rem; }
.bubble li { margin: .15rem 0; }
.msg-meta { font-size: 12px; color: var(--text-3); display: flex; gap: .35rem; align-items: center; }
.msg-meta svg.icon { width: 13px; height: 13px; }
.typing .bubble { display: flex; gap: 5px; padding: .95rem 1rem; }
.typing .bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing .bubble i:nth-child(2) { animation-delay: .2s; }
.typing .bubble i:nth-child(3) { animation-delay: .4s; }

/* cards inside chat */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .95rem; box-shadow: var(--shadow); font-size: 14px; }
.ticket-card { cursor: pointer; display: grid; gap: .3rem; transition: border-color .15s; min-width: 260px; }
.ticket-card:hover { border-color: var(--primary); }
.ticket-card .top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.ticket-card .num { font-family: var(--mono); font-weight: 700; font-size: 13px; color: var(--primary); }
.ticket-card .subj { font-weight: 600; }
.ticket-card .sub { font-size: 12.5px; color: var(--text-3); }
.tickets-card h4 { margin: 0 0 .5rem; font-size: 13px; color: var(--text-2); }
.tickets-card .trow { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .45rem .3rem; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.tickets-card .trow:hover { background: var(--surface-2); }
.tickets-card .trow .num { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--primary); }
.tickets-card .trow .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secret-card { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: linear-gradient(0deg, var(--success-soft), var(--surface) 70%); }
.secret-card h4 { margin: 0 0 .5rem; display: flex; gap: .4rem; align-items: center; font-size: 14px; }
.secret-value { display: flex; align-items: center; gap: .4rem; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 9px; padding: .35rem .35rem .35rem .75rem; }
.secret-value code { background: none; padding: 0; font-size: 16px; letter-spacing: .06em; flex: 1; overflow-wrap: anywhere; }
.secret-card .note { font-size: 12.5px; color: var(--text-3); margin-top: .5rem; }
.dev-card { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); box-shadow: none; font-size: 13px; }
.dev-card a { word-break: break-all; font-weight: 600; color: inherit; text-decoration: underline; }
.options { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--primary); font: inherit; font-size: 13.5px; font-weight: 600; padding: .38rem .8rem; border-radius: 999px; cursor: pointer; transition: background .15s, border-color .15s; }
.chip:hover { background: var(--primary-soft); border-color: var(--primary); }
.chip:disabled { color: var(--text-3); cursor: default; background: var(--surface); border-color: var(--border); }
.summary-card h4 { margin: 0 0 .5rem; font-size: 14px; }
.steps-card { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.steps-card h4 { display: flex; gap: .45rem; align-items: center; margin: 0 0 .6rem; font-size: 14.5px; }
.steps-card h4 svg.icon { color: var(--primary); }
.steps-card ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.steps-card li label { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; line-height: 1.45; }
.steps-card li input { margin-top: .22rem; width: 16px; height: 16px; flex: none; accent-color: var(--success); }
.steps-card li.done span { color: var(--text-3); text-decoration: line-through; }
.steps-card .note { font-size: 12.5px; color: var(--text-3); margin: .6rem 0 0; }
.steps-card.escalate { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: linear-gradient(0deg, var(--danger-soft), var(--surface) 75%); }
.steps-card.escalate h4 svg.icon { color: var(--danger); }
.contact-card { display: grid; grid-template-columns: auto 1fr; gap: .4rem .8rem; align-items: start; background: var(--surface-2); border-radius: 12px; padding: .85rem; }
.contact-card .contact-info { min-width: 0; overflow-wrap: anywhere; line-height: 1.55; }
.contact-card .contact-actions { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; }
.contact-card .contact-actions a:hover { text-decoration: none; }
.steps-tried-title { margin: .9rem 0 .3rem; }
.steps-tried { margin: 0; padding-left: 1.2rem; color: var(--text-2); }
.drawer-title { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* composer */
.composer-wrap { flex: none; padding: .6rem clamp(1rem, 4vw, 3rem) .9rem; }
.composer { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: .3rem; padding: .35rem; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer textarea { border: none; box-shadow: none !important; resize: none; min-height: 40px; max-height: 180px; padding: .55rem .4rem; background: transparent; line-height: 1.45; }
.composer-meta { max-width: 820px; margin: .45rem auto 0; display: flex; justify-content: space-between; gap: 1rem; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }


/* ---------------------------------------------------------------- tables & lists */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; padding: .75rem .9rem; background: var(--surface-2); white-space: nowrap; }
td { padding: .7rem .9rem; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td .num { font-family: var(--mono); font-weight: 700; color: var(--primary); font-size: 13px; white-space: nowrap; }
td .subj { font-weight: 600; }
td select { width: auto; padding: .35rem .5rem; font-size: 13.5px; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-3); }
.empty-state svg.icon { width: 40px; height: 40px; margin-bottom: .6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .label { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat.warn .value { color: var(--warning); }
.stat.bad .value { color: var(--danger); }

/* ---------------------------------------------------------------- drawer & dialogs */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 30, .35); z-index: 60; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 61; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease-out; }
.drawer-head { padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; align-items: flex-start; }
.drawer-head .num { font-family: var(--mono); color: var(--primary); font-weight: 700; font-size: 13px; }
.drawer-head h2 { font-size: 18px; margin: .2rem 0 .4rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.2rem 1.3rem 2rem; }
.drawer-section { margin-bottom: 1.4rem; }
.drawer-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: .6rem; }
.desc { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: .75rem .9rem; font-size: 14px; }
.staff-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; background: var(--surface-2); padding: .8rem; border-radius: 12px; }
.staff-actions select { width: auto; padding: .4rem .6rem; font-size: 13.5px; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.tasks li label { display: flex; gap: .55rem; align-items: flex-start; font-size: 14px; cursor: pointer; }
.tasks li input { margin-top: .2rem; accent-color: var(--success); }
.tasks li.done span { color: var(--text-3); text-decoration: line-through; }
.progress { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; margin-bottom: .7rem; }
.progress > i { display: block; height: 100%; background: var(--success); border-radius: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: .6rem; }
.timeline .tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.timeline li.event .tl-dot { background: transparent; border: 2px solid var(--surface-3); }
.timeline .tl-body { font-size: 14px; }
.timeline .tl-meta { font-size: 12px; color: var(--text-3); }
.timeline li.event .tl-text { color: var(--text-2); }
.timeline li.comment .tl-text { background: var(--surface-2); padding: .5rem .75rem; border-radius: 10px; margin-top: .2rem; white-space: pre-wrap; }
.timeline li.internal .tl-text { background: var(--warning-soft); }
.comment-form textarea { min-height: 70px; }
.comment-form .row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }

dialog { border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(520px, calc(100% - 2rem)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 12, 30, .45); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.3rem .4rem; }
dialog .dlg-head h2 { margin: 0; font-size: 18px; }
dialog .dlg-body { padding: .6rem 1.3rem 1.3rem; max-height: 75vh; overflow-y: auto; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
dialog hr { border: none; border-top: 1px solid var(--border); margin: 1.3rem 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }

.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); z-index: 100; max-width: min(520px, calc(100% - 2rem)); background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .2s; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------------------------------------------------------------- animation */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { padding: 2.2rem 1.4rem; }
  .auth-hero .brand { margin-bottom: 1.2rem; }
  .feature-list { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 .6rem; gap: .4rem; }
  .brand span { display: none; }
  .tabs { margin-left: 0; }
  .tab { padding: .45rem .55rem; font-size: 13px; }
  #engine-badge { display: none; }
  .quick-grid { grid-template-columns: 1fr; }
  .msg-body { max-width: 88%; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-card { padding: 1.4rem; }
  .auth-hero .feature-list { display: none; }
  .banner { font-size: 13px; gap: .4rem .6rem; padding: .45rem .8rem; }
  .banner > svg.icon { display: none; }
}
