:root {
  --ink: #232731;
  --ink-2: #545967;
  --muted: #8A8F9C;
  --line: #E4EAEE;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --red: #EF252B;
  --red-dark: #C81D22;
  --red-soft: #FDE7E8;
  --green: #1F9D55;
  --green-soft: #E3F5EA;
  --amber: #B7791F;
  --amber-soft: #FDF3DD;
  --blue: #2F6FDB;
  --blue-soft: #E6EEFC;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 39, 49, .04), 0 4px 16px rgba(35, 39, 49, .06);
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --head: 'Jost', 'Onest', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; margin: 0; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; border: 48px solid var(--red); opacity: .9; }
.auth-side h1 { font-size: 40px; max-width: 420px; margin-top: 48px; }
.auth-side h1 span { color: var(--red); }
.auth-side ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; color: #C9CCD4; max-width: 380px; }
.auth-side li::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 12px; vertical-align: middle; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 28px; margin-bottom: 6px; }
.auth-card .tabs { margin: 24px 0; }
.auth-mobile-logo { display: none; margin-bottom: 28px; }
.code-input { letter-spacing: .5em; font-size: 24px !important; text-align: center; font-family: var(--head) !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 24px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .logo { padding: 4px 12px 28px; display: flex; align-items: center; gap: 12px; }
.sidebar .logo span { font-family: var(--head); font-size: 13px; color: #A7A7A7; line-height: 1.2; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: #C9CCD4; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--red); color: #fff; }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .badge { margin-left: auto; background: rgba(255,255,255,.18); color: #fff; font-size: 12px; padding: 1px 8px; border-radius: 99px; }
.nav a.active .badge { background: rgba(255,255,255,.25); }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #A7A7A7; }
.sidebar-foot b { display: block; color: #fff; font-weight: 500; font-size: 14px; }
.main { min-width: 0; padding: 32px 40px 64px; max-width: 1240px; width: 100%; }
.topbar { display: none; }
.tabbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 12px; }
.back:hover { color: var(--ink); }

/* ---------- components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat { display: flex; flex-direction: column; gap: 6px; text-decoration: none; transition: transform .15s; }
a.stat:hover { transform: translateY(-2px); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-family: var(--head); font-size: 30px; font-weight: 600; line-height: 1.1; }
.stat .hint { font-size: 13px; color: var(--ink-2); }
.stat.accent { background: var(--ink); color: #fff; }
.stat.accent .label { color: #A7A7A7; }
.stat.accent .hint { color: #C9CCD4; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--red); color: #fff; text-decoration: none; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: var(--red-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--bg); color: var(--ink); }
.btn.secondary:hover { background: var(--line); }
.btn.ghost { background: transparent; color: var(--ink-2); padding: 8px 10px; }
.btn.ghost:hover { background: var(--bg); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(35,39,49,.08); }
textarea.input { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--ink-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red-dark); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; min-width: 0; }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
a.list-item:hover .li-title { color: var(--red); }
.li-body { flex: 1; min-width: 0; }
.li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.li-meta { font-size: 13px; color: var(--muted); }
.li-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--bg); display: grid; place-items: center; flex: none; color: var(--ink-2); }
.li-icon svg { width: 20px; height: 20px; }
.li-icon.red { background: var(--red-soft); color: var(--red); }
.amount { font-family: var(--head); font-weight: 600; font-size: 17px; white-space: nowrap; }

/* services */
.service-type { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--red); }
.progress { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.progress > div { height: 100%; background: var(--red); border-radius: 99px; transition: width .4s; }
.progress.dark > div { background: var(--ink); }
.stages { display: grid; gap: 0; margin-top: 18px; }
.stage { display: flex; gap: 14px; align-items: flex-start; position: relative; padding-bottom: 14px; }
.stage:last-child { padding-bottom: 0; }
.stage::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.stage:last-child::before { display: none; }
.stage.done::before { background: var(--ink); }
.dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: #fff; flex: none; display: grid; place-items: center; position: relative; z-index: 1; }
.stage.done .dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.stage.current .dot { border-color: var(--red); }
.stage.current .dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.6s infinite; }
.dot svg { width: 14px; height: 14px; }
.stage-title { padding-top: 1px; }
.stage.todo .stage-title { color: var(--muted); }
.stage.current .stage-title { font-weight: 600; }
.stage-controls { margin-left: auto; display: flex; gap: 4px; }

/* tickets */
.thread { display: grid; gap: 14px; }
.msg { max-width: 78%; padding: 14px 16px; border-radius: 16px; background: var(--bg); white-space: pre-wrap; word-wrap: break-word; }
.msg.mine { margin-left: auto; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { border-bottom-left-radius: 4px; }
.msg-meta { font-size: 12px; opacity: .65; margin-bottom: 4px; }

/* manager */
.manager { display: flex; gap: 14px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-family: var(--head); font-weight: 600; font-size: 20px; flex: none; }
.contact-links { display: grid; gap: 8px; margin-top: 16px; }
.contact-links a { display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-weight: 500; font-size: 14px; }
.contact-links a:hover { background: var(--line); }
.contact-links svg { width: 18px; height: 18px; color: var(--red); }

/* table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 12px 12px; }
.table td { padding: 14px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; text-align: right; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: #FAFBFC; }
.table-wrap { overflow-x: auto; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(35, 39, 49, .5); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 20px; padding: 28px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; animation: rise .2s; }
.modal h2 { margin-bottom: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

/* toast */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); animation: rise .2s; font-weight: 500; }
.toast.error { background: var(--red); }

.install-banner { display: flex; gap: 14px; align-items: center; background: var(--ink); color: #fff; }
.install-banner .li-icon { background: rgba(255,255,255,.1); color: #fff; }

/* tips */
.tip-btn { background: var(--red-soft); color: var(--red-dark); }
.tip-btn:hover { background: #FBD3D5; }
.btn svg { width: 18px; height: 18px; }
.choice-list { display: grid; gap: 8px; }
.choice input, .chip input { position: absolute; opacity: 0; pointer-events: none; }
.choice-box { display: grid; gap: 2px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice input:checked + .choice-box { border-color: var(--red); background: var(--red-soft); }
.choice input:focus-visible + .choice-box, .chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(239,37,43,.25); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip span { display: inline-block; padding: 9px 16px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-weight: 600; transition: all .15s; }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- mobile ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-mobile-logo { display: block; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; }
  .topbar .btn.ghost { color: #fff; }
  .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; text-decoration: none; font-size: 11px; color: var(--muted); font-weight: 500; position: relative; }
  .tabbar a.active { color: var(--red); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); background: var(--red); color: #fff; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; padding: 0 4px; }
  h1 { font-size: 24px; }
  .card { padding: 18px; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stat .value { font-size: 24px; }
  .msg { max-width: 92%; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 0; border-top: 1px solid var(--line); }
  .table.responsive tr:first-child { border-top: 0; }
  .table.responsive td { border: 0; padding: 0 !important; text-align: left !important; }
  .table.responsive td.r { text-align: right !important; }
}
