/* MA-Engineers customer portal.
   One light surface (office daylight, Windows workstations), MA-Engineers navy for actions and state only.
   Elevation is borders, never shadows, except floating menus. System UI face; mono only for keys, IDs and codes. */

:root {
    --navy: #344a86;
    --navy-600: #2c3f74;
    --navy-700: #24345f;
    --navy-50: #eef1f8;
    --navy-100: #dde3f0;

    --ink: #1b2333;
    --ink-2: #4b5568;
    --ink-3: #646c7e;

    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --line: #dce0e7;
    --line-2: #e9ecf1;

    --ok: #1a7f4b;
    --ok-bg: #e5f3eb;
    --warn: #8a5a00;
    --warn-bg: #fbf0d9;
    --warn-line: #ecd6a6;
    --bad: #b42318;
    --bad-bg: #fbeae8;
    --muted-bg: #eef0f3;

    --st-open: #1a7f4b;
    --st-needsinfo: #a86b00;
    --st-inprogress: var(--navy);
    --st-closed: #646c7e;

    --radius: 6px;
    --radius-lg: 8px;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", ui-monospace, Menlo, monospace;
    --page: 1080px;

    color-scheme: light;
    accent-color: var(--navy);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: #c3c8d2 transparent; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 400 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--navy-100); color: var(--ink); }

h1, h2, h3 { margin: 0; color: var(--ink); text-wrap: balance; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1rem; line-height: 1.4; font-weight: 600; }
p { margin: 0; }
a { color: var(--navy); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--navy-700); }
hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }
strong { font-weight: 600; }
small, .small { font-size: 0.8125rem; }
code, pre, .mono { font-family: var(--mono); font-size: 0.8125rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-2); }
.measure { max-width: 68ch; }
.center { text-align: center; }

:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 3px; }

.visually-hidden {
    position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 !important;
}
.skip { position: absolute; left: -9999px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { left: 16px; }

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

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

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner {
    max-width: var(--page); margin: 0 auto; padding: 0 24px; height: 56px;
    display: flex; align-items: center; gap: 32px;
}
.is-staff .topbar-inner { max-width: 1240px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { display: block; height: 20px; width: auto; }
.brand-tag {
    font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--navy); background: var(--navy-50); border-radius: 4px; padding: 2px 6px;
}
.mainnav { display: flex; align-self: stretch; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mainnav a {
    display: flex; align-items: center; padding: 0 12px; color: var(--ink-2); text-decoration: none;
    font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a.on { color: var(--ink); border-bottom-color: var(--navy); }

.usermenu { position: relative; flex: none; }
.usermenu summary {
    list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 4px 8px 4px 4px; border-radius: 999px; color: var(--ink-2);
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-2); color: var(--ink); }
.usermenu-name { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel, .menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; z-index: 20;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px -8px rgba(27, 35, 51, 0.18), 0 2px 6px -2px rgba(27, 35, 51, 0.08);
    padding: 6px; display: grid;
}
.usermenu-panel a, .usermenu-panel .linkbutton, .menu-item {
    display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 4px;
    color: var(--ink); text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer;
}
.usermenu-panel a:hover, .usermenu-panel .linkbutton:hover, .menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--bad); }

.avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
    background: var(--navy-50); color: var(--navy); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.avatar-lg { width: 36px; height: 36px; font-size: 0.8125rem; }

.langswitch { display: flex; gap: 2px; margin-left: auto; }
.langswitch button {
    font: inherit; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; padding: 4px 8px;
    border: 0; background: none; color: var(--ink-3); border-radius: 4px; cursor: pointer;
}
.langswitch button:hover { color: var(--ink); background: var(--surface-2); }
.langswitch button.on { color: var(--navy); background: var(--navy-50); }

/* ---------- Page ---------- */

.page { flex: 1; width: 100%; max-width: var(--page); margin: 0 auto; padding: 32px 24px 64px; }
.is-staff .page { max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.backlink {
    display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none;
    font-size: 0.8125rem; margin-bottom: 12px;
}
.backlink:hover { color: var(--navy); }
.section { margin-top: 32px; }
.section > h2 { margin-bottom: 12px; }
.section-intro { margin-bottom: 16px; }
.listing-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.count {
    display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
    background: var(--muted-bg); color: var(--ink-2); font-size: 0.75rem; font-weight: 600; text-align: center;
    font-variant-numeric: tabular-nums; line-height: 20px;
}

/* The rule spans the content column only, so the gutter lives in the width, not the padding. */
.footer {
    width: calc(100% - 48px); max-width: calc(var(--page) - 48px); margin: 0 auto; padding: 20px 0 32px;
    display: flex; gap: 16px; justify-content: space-between; color: var(--ink-3); font-size: 0.8125rem;
    border-top: 1px solid var(--line-2);
}
.is-staff .footer { max-width: calc(1240px - 48px); }
.footer a { color: var(--ink-3); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-pad { padding: 20px; }
.panel > h2, .panel-pad > h2 { margin-bottom: 12px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: #bfe0cc; color: #12583a; }
.flash-bad { background: var(--bad-bg); border-color: #f0c4be; color: #8c1c13; }

.callout {
    padding: 14px 16px; border-radius: var(--radius-lg); background: var(--navy-50); border: 1px solid var(--navy-100);
    margin-bottom: 20px; display: grid; gap: 8px; justify-items: start;
}
.callout-warn { background: var(--warn-bg); border-color: var(--warn-line); color: #5f3e00; display: flex; align-items: center; gap: 8px; }
.callout .keyblock { justify-self: stretch; }
.quote { white-space: pre-wrap; border-left: 2px solid var(--line); padding-left: 12px; color: var(--ink-2); margin-top: 8px; }

.empty { padding: 40px 24px; text-align: center; display: grid; gap: 4px; justify-items: center; color: var(--ink-2); }
.empty strong { color: var(--ink); }
.empty-page { max-width: 480px; margin: 48px auto; display: grid; gap: 12px; justify-items: center; text-align: center; }

/* ---------- Home: the three actions ---------- */

.actions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 40px; }
.action-tile {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 16px; row-gap: 2px;
    align-items: center; padding: 22px 20px; text-decoration: none; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.action-tile:hover { border-color: var(--navy); color: var(--ink); background: #fcfcfe; }
.action-tile:hover .action-icon { background: var(--navy); color: #fff; }
.action-icon {
    grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
    background: var(--navy-50); color: var(--navy); transition: background-color 150ms ease-out, color 150ms ease-out;
}
.action-icon .icon { width: 22px; height: 22px; }
.action-title { font-size: 1rem; font-weight: 600; }
.action-hint { color: var(--ink-2); font-size: 0.8125rem; }

/* ---------- Lists (GitHub-style rows) ---------- */

.listing { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.listing > .listing-head { padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.listing > .empty { border: 0; }

.tabs { display: flex; gap: 4px; }
.tabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius);
    color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.tabs a:hover { color: var(--ink); background: var(--muted-bg); }
.tabs a.on { color: var(--ink); font-weight: 600; }
.tabs-line { border-bottom: 1px solid var(--line); gap: 8px; margin-bottom: 20px; }
.tabs-line a { border-radius: 0; padding: 8px 4px; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs-line a:hover { background: none; }
.tabs-line a.on { border-bottom-color: var(--navy); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
    display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-2);
}
.rows > .row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row-state { padding-top: 2px; color: var(--ink-3); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; color: var(--ink); text-decoration: none; margin-right: 6px; overflow-wrap: anywhere; }
.row-title:hover { color: var(--navy); text-decoration: underline; }
.row-title-plain { font-weight: 600; margin-right: 6px; }
.row-meta { color: var(--ink-3); font-size: 0.8125rem; margin-top: 2px; }
.row-note { color: var(--ink-2); margin-top: 6px; white-space: pre-wrap; }
.row-comments { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 0.8125rem; padding-top: 2px; }
.row form { flex: none; }

.status-open { color: var(--st-open); }
.status-needsinfo { color: var(--st-needsinfo); }
.status-inprogress { color: var(--st-inprogress); }
.status-closed { color: var(--st-closed); }

.label {
    display: inline-block; font-size: 0.75rem; font-weight: 500; line-height: 18px; padding: 0 7px;
    border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); vertical-align: 1px; white-space: nowrap;
}
.label-bug { border-color: #efc7c2; color: #9b2c22; background: #fdf3f2; }
.label-feature { border-color: var(--navy-100); color: var(--navy); background: var(--navy-50); }
.label-support { border-color: #cfe3d7; color: #1d6b43; background: #f1f8f4; }

.pill {
    display: inline-block; font-size: 0.75rem; font-weight: 600; line-height: 20px; padding: 0 8px;
    border-radius: 999px; white-space: nowrap; vertical-align: 1px;
}
.pill-lg { font-size: 0.8125rem; line-height: 26px; padding: 0 12px; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--navy-50); color: var(--navy); }
.pill-muted, .pill-closed { background: var(--muted-bg); color: var(--ink-2); }

.badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 0.6875rem; font-weight: 600; line-height: 18px;
    padding: 0 6px; border-radius: 4px; background: var(--navy-50); color: var(--navy); vertical-align: 1px; margin-left: 4px;
}
.badge .icon { width: 12px; height: 12px; vertical-align: 0; }
.badge-muted { background: var(--muted-bg); color: var(--ink-2); }
.badge-internal { background: var(--warn-bg); color: var(--warn); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); padding: 10px 16px;
    background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--radius-lg); }
.table th:last-child { border-top-right-radius: var(--radius-lg); }
.table td { padding: 11px 16px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.table td.num.nowrap, .table td.nowrap.num { text-align: left; }
.table-dense td { padding: 7px 12px; font-size: 0.8125rem; }
.table-dense th { padding: 8px 12px; }
.cell-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.cell-link:hover { color: var(--navy); text-decoration: underline; }
.cell-actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-actions form { display: inline; }
tr.is-off td { color: var(--ink-3); }

.menu { position: relative; display: inline-block; text-align: left; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel { min-width: 230px; }
.menu-wide .menu-panel { width: min(420px, 90vw); padding: 16px; }

/* ---------- Forms ---------- */

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.stack-sm { gap: 8px; }
.form-narrow { max-width: 640px; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend, .field > summary { font-weight: 600; font-size: 0.8125rem; color: var(--ink); padding: 0; }
.field > summary { cursor: pointer; color: var(--navy); font-weight: 500; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.field-row > .field { flex: 1 1 200px; }
.field-row > .field-shrink, .inline-form > .field-shrink { flex: 0 0 auto; }
.optional { font-weight: 400; color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 0.8125rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"],
input[type="number"], input[type="date"], input:not([type]), select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid #c9ced8; border-radius: var(--radius); padding: 7px 10px; min-height: 36px;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}
textarea { resize: vertical; line-height: 1.5; min-height: 80px; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 0.8125rem; }
input::placeholder, textarea::placeholder { color: #7b8292; }
input:hover, select:hover, textarea:hover { border-color: #aeb4c0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(52, 74, 134, 0.16); }
input[type="number"] { width: 90px; }
input[type="date"] { min-width: 160px; }
select {
    appearance: none; padding-right: 30px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%234b5568' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
select:disabled, input:disabled { background-color: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.select-compact { width: auto; min-width: 180px; }
.code-input { font-size: 1.125rem; letter-spacing: 0.2em; text-align: center; max-width: 200px; }

.check, .choice { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.check input, .choice input { width: 16px; height: 16px; margin: 0; }
.choice-row { display: flex; gap: 20px; flex-wrap: wrap; }

.form-error {
    background: var(--bad-bg); color: #8c1c13; border: 1px solid #f0c4be; border-radius: var(--radius); padding: 9px 12px;
}

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.inline-form > .field { flex: 1 1 200px; }
.inline-form > .check { min-height: 36px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 170px; }
.filters input[type="search"] { flex: 1 1 240px; }

.segmented { display: inline-flex; border: 1px solid #c9ced8; border-radius: var(--radius); padding: 3px; gap: 3px; background: var(--surface); margin: 0; }
.segment { position: relative; cursor: pointer; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 4px; color: var(--ink-2); font-weight: 500;
    transition: background-color 120ms ease-out, color 120ms ease-out;
}
.segment:hover span { color: var(--ink); background: var(--surface-2); }
.segment input:checked + span { background: var(--navy); color: #fff; }
.segment input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
    font: inherit; font-weight: 600; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
    text-decoration: none; white-space: nowrap; transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-600); color: #fff; }
.btn-primary:active { background: var(--navy-700); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: #c9ced8; }
.btn-secondary:hover { border-color: #9fa6b4; color: var(--ink); background: var(--surface-2); }
.btn-ghost { background: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--muted-bg); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #e9b8b2; }
.btn-danger:hover { background: var(--bad-bg); color: #8c1c13; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.btn-block { width: 100%; white-space: normal; }
.btn.is-done { color: var(--ok); }
.linkbutton { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--navy); }
.quiet-link { color: var(--ink-2); font-size: 0.8125rem; justify-self: center; text-decoration: none; }
.quiet-link:hover { color: var(--navy); text-decoration: underline; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Ticket ---------- */

.ticket-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.ticket-head h1 { font-size: 1.625rem; font-weight: 500; overflow-wrap: anywhere; }
.ticket-number { color: var(--ink-3); font-weight: 400; }
.ticket-sub { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.state {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; line-height: 30px; border-radius: 999px;
    color: #fff; font-weight: 600; font-size: 0.8125rem;
}
.state .icon { color: #fff; }
.state-open { background: var(--st-open); }
.state-needsinfo { background: var(--st-needsinfo); }
.state-inprogress { background: var(--st-inprogress); }
.state-closed { background: var(--st-closed); }

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; align-items: start; }
.ticket-side { position: sticky; top: 80px; display: grid; gap: 20px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 66px; top: 0; bottom: 0; width: 2px; background: var(--line-2); }
.tl-comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; position: relative; margin-bottom: 20px; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); position: relative; min-width: 0; }
.comment-head {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 8px 16px; background: var(--surface-2);
    border-bottom: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; color: var(--ink-2);
}
.comment-head strong { color: var(--ink); margin-right: 2px; }
.comment-time { margin-left: auto; color: var(--ink-3); text-decoration: none; font-size: 0.8125rem; }
.comment-time:hover { color: var(--navy); text-decoration: underline; }
.comment-body { padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.from-staff .comment { border-color: var(--navy-100); }
.from-staff .comment-head { background: var(--navy-50); border-bottom-color: var(--navy-100); }
.from-staff .avatar { background: var(--navy); color: #fff; }
.is-internal .comment { border-color: var(--warn-line); border-style: dashed; }
.is-internal .comment-head { background: var(--warn-bg); border-bottom-color: var(--warn-line); }
.attachments { list-style: none; margin: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line-2); display: grid; gap: 4px; }
.comment-body + .attachments { border-top: 1px dashed var(--line-2); }
.attachments li { display: flex; gap: 8px; align-items: center; font-size: 0.8125rem; }
.attachments a { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.attachments a:hover span { text-decoration: underline; }

.tl-event { display: flex; align-items: center; gap: 12px; margin: 0 0 20px 52px; position: relative; color: var(--ink-2); }
.tl-event p { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-event strong { color: var(--ink); }
.tl-event-icon {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--surface); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line);
}

.reply { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; margin-top: 8px; padding-top: 20px; border-top: 2px solid var(--line-2); position: relative; background: var(--bg); }
.comment-compose { padding: 12px; display: grid; gap: 12px; }
.comment-compose textarea { min-height: 120px; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.compose-options { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.compose-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filepick { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); cursor: pointer; font-size: 0.8125rem; }
.filepick:hover { color: var(--navy); }
.field > .filepick-box, .filepick-box {
    display: flex; font-weight: 400; color: var(--ink-2); width: 100%; padding: 12px 14px; font-size: 0.875rem;
    background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.filepick-box:hover { border-color: var(--navy); color: var(--navy); }
.filepick:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 3px; }
.reply.is-internal .comment { border-color: var(--warn-line); border-style: dashed; background: #fffdf8; }

.facts { display: grid; gap: 14px; margin: 0; }
.facts dt { font-size: 0.75rem; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-inline { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 24px; margin-top: 20px; }
.panel.facts-inline, .panel-pad > .facts-inline:first-child { margin-top: 0; }
.facts + h2 { margin-top: 24px; margin-bottom: 8px; }
.side-form { padding-top: 16px; border-top: 1px solid var(--line); }
.side-form .field > label { font-size: 0.75rem; color: var(--ink-3); }

/* ---------- Licenses ---------- */

.license-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.keyblock {
    margin: 0 0 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius); white-space: pre-wrap; word-break: break-all; line-height: 1.55; color: var(--ink);
    max-height: 200px; overflow: auto;
}
.license-actions h2 { margin-bottom: 8px; }
.linklist { list-style: none; margin: 0; padding: 0; display: grid; }
.linklist li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.linklist li:first-child { border-top: 0; padding-top: 4px; }
.linklist a { font-weight: 600; }
.linklist .muted { font-size: 0.8125rem; }
.summary-line { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.older { margin-top: 24px; }
.older > summary { cursor: pointer; color: var(--ink-2); font-weight: 500; margin-bottom: 12px; }
.plainlist { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Account ---------- */

.settings { display: grid; gap: 32px; }
.settings-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.settings-intro { padding-top: 4px; display: grid; gap: 4px; }
.settings-row .panel { max-width: 560px; }

/* ---------- Sign-in pages ---------- */

body.auth { background: var(--bg); }
.auth-main { width: 100%; max-width: 440px; margin: 0 auto; padding: 64px 20px 40px; flex: 1; display: grid; align-content: start; gap: 20px; }
.auth-head { display: flex; align-items: center; justify-content: space-between; }
.auth-head img { height: 26px; width: auto; display: block; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 1.375rem; }
.auth-card .lede { color: var(--ink-2); }
.auth-card .stack { gap: 14px; }
.auth-foot { color: var(--ink-3); font-size: 0.8125rem; text-align: center; }
.lede { color: var(--ink-2); max-width: 60ch; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 12px; color: var(--ink); }
.steps li::marker { color: var(--ink-3); font-weight: 600; }
.qr { width: 184px; height: 184px; margin: 12px 0 8px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.qr svg { width: 100%; height: 100%; display: block; }
.manual-key summary { cursor: pointer; color: var(--navy); font-size: 0.8125rem; }
.manual-key .keyblock { margin-top: 8px; letter-spacing: 0.06em; }
.codes {
    margin: 0; padding: 14px 16px 14px 40px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.875rem;
}
/* Stacked rows on phones: each cell carries its column name in data-label. */
@media (max-width: 760px) {
    .table-stack { overflow: visible; }
    .table-stack thead { display: none; }
    .table-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 16px; padding: 14px 16px; border-top: 1px solid var(--line-2); }
    .table-stack tbody tr:first-child { border-top: 0; }
    .table-stack td { display: block; padding: 0; border: 0; }
    .table-stack tbody tr:hover td { background: none; }
    .table-stack td[data-label]::before {
        content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 600; color: var(--ink-3); margin-bottom: 2px;
    }
    .table-stack td.stack-title { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .table-stack td.stack-hide { display: none; }
    .table-stack .nowrap { white-space: normal; }
}
.stack-only { display: none; }
@media (max-width: 760px) { .stack-only { display: inline-flex; } }

.codes li::marker { color: var(--ink-3); font-family: var(--font); font-size: 0.75rem; }

/* ---------- Small screens ---------- */

@media (max-width: 960px) {
    .ticket-layout, .license-layout { grid-template-columns: minmax(0, 1fr); }
    .ticket-side { position: static; order: -1; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
    .ticket-side .facts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .settings-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 760px) {
    /* Two rows: brand and account on top, the menu as a full-width (scrollable) strip below. */
    .topbar-inner { padding: 0 16px; gap: 0 16px; height: auto; flex-wrap: wrap; }
    .brand, .usermenu, .langswitch { height: 52px; display: flex; align-items: center; }
    .usermenu { margin-left: auto; }
    .mainnav { order: 3; flex: 1 0 100%; height: 44px; margin: 0 -16px; padding: 0 8px; border-top: 1px solid var(--line-2); }
    .brand img { height: 17px; }
    .brand-tag { display: none; }
    .usermenu-name { display: none; }
    .mainnav a { padding: 0 8px; }
    .page { padding: 24px 16px 48px; }
    .actions-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 28px; }
    .action-tile { padding: 16px; }
    h1 { font-size: 1.3125rem; }
    .ticket-head h1 { font-size: 1.3125rem; }
    .timeline::before { left: 15px; }
    .tl-comment, .reply { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .tl-comment > .avatar, .reply > .avatar { display: none; }
    .tl-event { margin-left: 0; }
    .timeline::before { display: none; }
    .row { padding: 12px; }
    .auth-main { padding-top: 32px; }
    .auth-card { padding: 24px 20px; }
    .codes { grid-template-columns: 1fr; }
    .footer { width: calc(100% - 32px); padding: 16px 0 24px; flex-direction: column; gap: 4px; }
    .filters select, .filters input { flex: 1 1 100%; }
    .compose-foot { flex-direction: column; align-items: stretch; }
    .compose-actions { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
