:root {
    --brand: #0f172a;
    --brand-dark: #020617;
    --accent: #2bb4e9;
    --accent-deep: #0b7fae;
    --accent-tint: #e8f7fd;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f4f6fb;
    --white: #ffffff;
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-width: 280px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, [type="button"], [type="submit"], a, label[for] { touch-action: manipulation; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
    background: var(--brand-dark); color: #fff;
    border-bottom: 1px solid rgba(43,180,233,.45);
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 24px; min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo {
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 9px; padding: 5px 7px; height: 40px;
    box-shadow: 0 1px 2px rgba(15,23,42,.35);
}
.brand-logo img { height: 30px; width: auto; display: block; }
.brand-text { font-weight: 700; font-size: 17px; line-height: 1.15; color: #fff; }
.brand-text small {
    display: block; font-size: 10.5px; font-weight: 500; letter-spacing: .06em;
    text-transform: uppercase; color: var(--accent);
}
.mainnav { display: flex; gap: 4px; margin-left: 12px; }
.mainnav a {
    color: #cbd5e1; padding: 8px 12px; border-radius: 6px; font-weight: 500;
}
.mainnav a:hover { background: rgba(43,180,233,.12); text-decoration: none; color: #fff; }
.mainnav a.active { background: rgba(43,180,233,.2); color: #fff; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { color: #cbd5e1; }

/* Layout */
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; min-height: 60vh; }
.footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: 13px; }
.footer .container { min-height: 0; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 6px 0 0; color: var(--muted); }

.panel {
    background: var(--white); border: 1px solid var(--line); border-radius: 10px;
    padding: 20px; margin-bottom: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }

/* Buttons */
.btn {
    display: inline-block; border: 1px solid transparent; border-radius: 8px;
    padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    text-align: center; background: #fff; color: var(--ink);
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.25); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { border-color: var(--line); color: var(--ink); background: #fff; }
.btn-outline:hover { border-color: #cbd5e1; }
.btn-plain { background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.field-error { color: #991b1b; font-size: 13px; margin-top: 4px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
/* Dashboard */
.dash-page { display: flex; flex-direction: column; gap: 22px; }
.dash-head { align-items: center; margin-bottom: 0; }
.dash-eyebrow {
    margin: 0 0 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--accent-deep);
}
.dash-page .page-head h1 { margin-bottom: 4px; font-size: 24px; letter-spacing: -0.01em; }
.dash-page .page-head .subtitle { margin: 0; }

.btn-icon {
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-icon svg { width: 18px; height: 18px; }

.stat-grid { grid-gap: 20px; }
.stat-card {
    display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 10px 32px rgba(16,24,40,.06);
}
.stat-icon {
    width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(15,23,42,.08);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-open { background: var(--accent-tint); color: var(--accent-deep); }
.stat-icon-progress { background: #fef7ea; color: #b45309; }
.stat-icon-resolved { background: #ecfdf5; color: #047857; }
.stat-icon-closed { background: #f1f5f9; color: #1e293b; }
.stat-copy { display: flex; flex-direction: column; gap: 2px; }
.stat-card .stat-value { font-size: 28px; line-height: .95; }
.stat-card .stat-label { color: var(--muted); font-size: 13.5px; }

.dash-panel { padding: 26px; border-radius: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 12px 38px rgba(16,24,40,.07); }
.dash-panel .panel-head { margin-bottom: 18px; }
.dash-panel .panel-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.link-ghost { color: var(--accent-deep); font-weight: 600; font-size: 13.5px; }

.table-wrap {
    max-width: 100%; overflow-x: auto; margin: -6px -4px; padding: 6px 4px;
    -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain;
}
.table-wrap:focus-visible { outline: 3px solid rgba(43,180,233,.35); outline-offset: 2px; }
.dash-table { min-width: 760px; }
.ticket-table { min-width: 820px; }
.dash-table th { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: #7a879c; background: #f8fafc; }
.dash-table tbody tr:hover td { background: #f8fafc; }
.dash-table td { padding: 12px 14px; vertical-align: middle; }
.dash-table .truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-table .muted { color: var(--muted); }
.dash-table .ticket-ref a { font-weight: 600; }
.action-col { text-align: right; white-space: nowrap; }

.btn-ghost {
    padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--accent-deep); font-weight: 600; font-size: 12.5px;
}
.btn-ghost:hover { border-color: var(--accent-deep); background: var(--accent-tint); text-decoration: none; }
.btn-xs { padding: 6px 10px; font-size: 12px; }

.empty-card {
    text-align: center; padding: 46px 24px; border: 1px dashed #d7dce6;
    border-radius: 12px; background: linear-gradient(180deg, #fff 0%, #fafbff 100%);
}
.empty-card h3 { margin: 0 0 6px; font-size: 17px; }
.empty-card p { margin: 0 0 16px; color: var(--muted); }
.empty-card .btn-sm { padding: 9px 16px; }

@media (max-width: 780px) {
    .dash-head { align-items: flex-start; flex-direction: column; gap: 12px; }
    .stat-card { padding: 16px 18px; }
    .dash-panel { padding: 20px; border-radius: 14px; }
    .dash-table { min-width: 700px; }
}

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.data-table tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-open { background: #e0f2fe; color: #075985; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-resolved { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-reopened { background: #ffe4e6; color: #9f1239; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(43,180,233,.22);
}
.req { color: #dc2626; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.form-actions { display: flex; gap: 10px; align-items: center; }

/* Screenshot dropzone */
.dropzone {
    margin-top: 8px; border: 2px dashed var(--line); border-radius: 10px; padding: 22px 16px;
    text-align: center; cursor: pointer; background: #fbfcfe;
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: #cbd5e1; }
.dropzone.dragging { border-color: var(--accent-deep); background: var(--accent-tint); }
.dropzone-text strong { display: block; color: var(--ink); }
.dropzone-text span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.file-list { list-style: none; margin: 10px 0 0; padding: 0; }
.file-list li {
    display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin-bottom: 6px;
    border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px;
}
.file-list li.has-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.file-list .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-list li.has-error .file-size { color: #991b1b; font-weight: 600; }
.file-list .file-remove {
    border: none; background: none; color: var(--accent-deep); cursor: pointer; font-size: 12px; padding: 2px 4px;
}
.file-list .file-remove:hover { text-decoration: underline; }

/* Ticket audio and video attachments */
.form-label {
    display: block; margin-bottom: 8px; color: #374151; font-size: 13px;
    font-weight: 600; letter-spacing: .01em;
}
.media-upload-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
}
.media-upload-card {
    min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px;
    background: #fafbfd;
}
.media-upload-head { margin-bottom: 14px; }
.media-upload-head h3 { margin: 0 0 3px; font-size: 15px; }
.media-upload-head span,
.media-file-label,
.media-status { color: var(--muted); font-size: 12.5px; }
.form-group .media-file-label { display: block; margin: 12px 0 6px; font-weight: 600; }
.media-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.media-status { min-height: 19px; margin: 10px 0 0; line-height: 1.5; overflow-wrap: anywhere; }
.media-status.is-error { color: #b42318; font-weight: 600; }
.media-status.is-success { color: #067647; }
.media-preview { display: block; width: 100%; max-width: 100%; margin-top: 12px; }
.media-video-preview { max-height: 260px; border-radius: 8px; background: #0f172a; }

.media-attachment-list { display: grid; gap: 14px; }
.media-attachment {
    min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd;
}
.media-attachment-meta { display: flex; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.media-attachment-meta strong { font-size: 14px; }
.media-attachment-meta span { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.media-playback { display: block; width: 100%; max-width: 100%; }
.media-video-playback { max-height: 520px; border-radius: 8px; background: #0f172a; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filter-bar input, .filter-bar select {
    padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}

.empty-state { color: var(--muted); padding: 8px 0; }
.prewrap { white-space: pre-wrap; margin: 0; }

/* Rich-text editor (ticket description) */
.ticket-editor {
    border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff;
}
.ticket-editor .toastui-editor-defaultUI {
    border: none; border-radius: 0;
}
.ticket-editor .toastui-editor-defaultUI-toolbar {
    background: #f8fafc; border-bottom: 1px solid var(--line);
}
.ticket-editor .ProseMirror {
    padding: 14px 16px;
}
.ticket-editor .toastui-editor-mode-switch {
    border-top: 1px solid var(--line);
}
.ticket-editor .toastui-editor-popup {
    z-index: 20;
}

/* Sanitized rich descriptions */
.rich-description { line-height: 1.6; overflow-wrap: break-word; }
.rich-description p { margin: 0 0 12px; }
.rich-description p:last-child { margin-bottom: 0; }
.rich-description ul, .rich-description ol { margin: 0 0 12px; padding-left: 24px; }
.rich-description img {
    max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line);
}
.rich-description blockquote {
    margin: 0 0 12px; padding: 4px 0 4px 14px; border-left: 3px solid var(--line); color: var(--muted);
}
.rich-description pre {
    margin: 0 0 12px; padding: 12px 14px; background: #f8fafc; border: 1px solid var(--line);
    border-radius: 8px; overflow-x: auto; font-size: 13px;
}
.rich-description code { background: #f1f5f9; border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.rich-description pre code { background: none; padding: 0; }
.rich-description table { border-collapse: collapse; margin: 0 0 12px; }
.rich-description th, .rich-description td {
    border: 1px solid var(--line); padding: 6px 10px; text-align: left;
}
.rich-description th { background: #f8fafc; }

/* Detail */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.detail-side .panel { padding: 16px 18px; }
.meta-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; text-align: right; }

.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.shot img {
    width: 100%; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
}

/* Timeline */
.timeline { list-style: none; margin: 0 0 18px; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 8px 0 12px 14px; }
.timeline li.from-staff { border-color: var(--accent); }
.timeline li.from-client { border-color: #86efac; }
.timeline-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.timeline-head strong { color: var(--ink); }

.history-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.history-list li:last-child { border-bottom: none; }
.history-status { font-weight: 600; }
.history-date { color: var(--muted); }

/* Pagination */
.pagination { margin-top: 16px; display: flex; gap: 6px; }
.pagination .page a, .pagination .page.current {
    display: inline-block; padding: 6px 11px; border: 1px solid var(--line);
    border-radius: 6px; background: #fff; font-size: 13px;
}
.pagination .page.current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Auth pages */
.auth-body {
    margin: 0; min-height: 100vh; background: #f2f5f9; color: var(--ink);
}
.auth-shell {
    display: grid; grid-template-columns: 46% minmax(0, 1fr); min-height: 100vh;
}

/* Brand panel — logo black + sky-blue accent */
.auth-brand-panel {
    position: relative; overflow: hidden; display: flex; flex-direction: column;
    justify-content: space-between; gap: 40px; padding: 46px 50px; color: #fff;
    background:
        radial-gradient(900px 520px at 110% -15%, rgba(43,180,233,.38), transparent 62%),
        linear-gradient(155deg, #05070d 0%, #0d1524 48%, #131c2e 100%);
}
.auth-brand-panel::after {
    content: ""; position: absolute; right: -110px; bottom: -140px;
    width: 340px; height: 340px; border-radius: 50%;
    background: rgba(43,180,233,.10); pointer-events: none;
}
.auth-logo-chip {
    position: relative; z-index: 1;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 12px; padding: 8px 10px; width: max-content;
    box-shadow: 0 10px 26px rgba(2,6,23,.45);
}
.auth-logo-chip img { height: 42px; width: auto; display: block; }
.auth-brand-copy { position: relative; z-index: 1; max-width: 30rem; }
.auth-eyebrow {
    margin: 0 0 16px; font-size: 11.5px; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--accent);
}
.auth-headline {
    margin: 0 0 16px; font-size: clamp(28px, 2.9vw, 40px); line-height: 1.14;
    letter-spacing: -0.02em; color: #fff;
}
.auth-lead { margin: 0 0 28px; font-size: 15px; line-height: 1.65; color: rgba(216,228,242,.82); }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 13px; }
.auth-points li { position: relative; padding-left: 30px; font-size: 14px; color: #dbe4f0; }
.auth-points li::before {
    content: ""; position: absolute; left: 0; top: 1px; width: 18px; height: 18px;
    border-radius: 50%; background: rgba(43,180,233,.16); border: 1px solid rgba(43,180,233,.55);
}
.auth-points li::after {
    content: ""; position: absolute; left: 5.5px; top: 6px; width: 7px; height: 4px;
    border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
    transform: rotate(-45deg);
}
.auth-panel-foot { position: relative; z-index: 1; margin: 0; font-size: 12.5px; color: rgba(165,186,214,.7); }

/* Form column */
.auth-main {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px; padding: 44px 24px;
}
.auth-card {
    width: 100%; max-width: 440px; background: #fff; border: 1px solid rgba(15,23,42,.07);
    border-radius: 18px; padding: 34px 32px 30px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 20px 46px rgba(16,24,40,.08);
}
.auth-steps { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-steps .step {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.auth-steps .step b {
    display: inline-flex; align-items: center; justify-content: center;
    width: 21px; height: 21px; border-radius: 50%; background: #eef1f6;
    color: var(--muted); font-size: 11px; font-weight: 700;
}
.auth-steps .step.is-done b { background: var(--accent-tint); color: var(--accent-deep); }
.auth-steps .step.is-active { color: var(--ink); }
.auth-steps .step.is-active b {
    background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(43,180,233,.22);
}
.auth-steps .step-sep {
    flex: 0 0 30px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--line));
}
.auth-title { margin: 0 0 8px; font-size: 21px; letter-spacing: -0.01em; color: var(--ink); }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; line-height: 1.6; }
.auth-sub b, .auth-sub strong { color: var(--ink); word-break: break-all; }
.auth-note { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.auth-main-foot { font-size: 13px; color: var(--muted); text-align: center; }
.auth-card .alert { border-radius: 10px; }

.input-icon { position: relative; }
.input-icon svg {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: #9aa5b5; pointer-events: none;
}
.form-group .input-icon input { padding-left: 42px; }

/* OTP entry */
.form-group input.otp-input {
    width: 100%; text-align: center; height: auto;
    padding: 18px 12px; font-size: 30px; font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: .38em; text-indent: .38em;
    border: 1px solid #e2e8f0; border-radius: 14px; background: #f8fafc; color: var(--ink);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-group input.otp-input::placeholder { color: #c3cbd6; letter-spacing: .38em; }
.form-group input.otp-input:hover { border-color: #cbd5e1; }
.form-group input.otp-input:focus {
    outline: none; background: #fff; border-color: var(--accent-deep);
    box-shadow: 0 0 0 4px rgba(43,180,233,.22);
}
.form-group input.otp-input.is-complete { border-color: var(--accent-deep); background: var(--accent-tint); }
.form-group input.otp-input.is-error { border-color: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.14); }
.form-group input.otp-input.is-shake { animation: auth-shake .4s ease; }
@keyframes auth-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}
@media (prefers-reduced-motion: no-preference) {
    .auth-card { animation: auth-in .38s ease both; }
    @keyframes auth-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

.auth-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; font-size: 13.5px; }
.auth-actions a { font-weight: 600; }
.auth-actions .auth-resend {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--accent-deep);
}
.auth-actions .auth-resend:hover { border-color: var(--accent-deep); background: var(--accent-tint); text-decoration: none; }

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand-panel { padding: 28px 24px; gap: 22px; }
    .auth-headline { font-size: 27px; }
    .auth-points { display: none; }
    .auth-lead { margin-bottom: 0; }
    .auth-main { padding: 30px 18px; }
    .auth-card { padding: 26px 22px 24px; border-radius: 16px; }
    .form-group input.otp-input { font-size: 26px; }
}

/* Create ticket page */
.create-page .page-head { align-items: center; margin-bottom: 24px; }
.create-page .page-head h1 { font-size: 24px; letter-spacing: -0.01em; }
.create-page .page-head .subtitle { max-width: 560px; }
.empty-panel { text-align: center; }

.create-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start;
}
.create-main {
    padding: 28px; border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
}
.create-main .form-group { margin-bottom: 22px; }
.create-main .form-group > label {
    font-size: 13px; color: #374151; letter-spacing: .01em; margin-bottom: 8px;
}
.create-main .form-group input[type="text"],
.create-main .form-group select {
    padding: 11px 14px; border-radius: 10px; border-color: #e2e8f0;
    transition: border-color .15s, box-shadow .15s;
}
.create-main .form-group input[type="text"]:hover,
.create-main .form-group select:hover { border-color: #cbd5e1; }
.create-main .form-group input[type="text"]:focus,
.create-main .form-group select:focus { border-color: var(--accent-deep); box-shadow: 0 0 0 4px rgba(43,180,233,.22); }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

.create-main .ticket-editor { border-radius: 10px; border-color: #e2e8f0; transition: border-color .15s, box-shadow .15s; }
.create-main .ticket-editor:focus-within { border-color: var(--accent-deep); box-shadow: 0 0 0 4px rgba(43,180,233,.22); }

.create-main .dropzone {
    padding: 26px 18px; border-radius: 12px; border-color: #dbe2ea; background: #fafbfd;
}
.create-main .dropzone.dragging { border-color: var(--accent-deep); background: var(--accent-tint); }

.create-main .form-actions { margin-top: 4px; padding-top: 20px; border-top: 1px solid var(--line); }
.create-main .btn { border-radius: 10px; padding: 10px 18px; }
.create-main .btn-primary {
    box-shadow: 0 1px 2px rgba(15,23,42,.3), 0 4px 14px rgba(43,180,233,.3);
    transition: background .15s, box-shadow .15s;
}
.create-main .btn-primary:hover { box-shadow: 0 2px 4px rgba(15,23,42,.35), 0 8px 20px rgba(43,180,233,.4); }

.create-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 20px; border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.side-card h2 { font-size: 14px; margin-bottom: 12px; }
.tips-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.tips-list li { margin-bottom: 6px; }
.side-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 960px) {
    .create-layout { grid-template-columns: 1fr; }
    .create-side { position: static; }
}

@media (max-width: 780px) {
    .detail-grid { grid-template-columns: 1fr; }
    .topbar-inner { flex-wrap: wrap; padding: 10px 16px; }
    .usermenu { margin-left: 0; }
    .create-main { padding: 20px; }
}

/* Mobile-first resilience: safe areas, touch targets and narrow layouts */
.detail-main,
.detail-side,
.create-main,
.auth-main,
.panel,
.stat-card { min-width: 0; }

.user-name {
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.filter-bar > input,
.filter-bar > select { flex: 1 1 160px; min-width: 0; }

.rich-description,
.prewrap,
.meta-list dd,
.history-status { overflow-wrap: anywhere; }

.rich-description table { max-width: 100%; }
.pagination { flex-wrap: wrap; }

.auth-body,
.auth-shell {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
}

@supports (padding: max(0px)) {
    .topbar { padding-top: env(safe-area-inset-top); }
    .topbar-inner,
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    .auth-brand-panel {
        padding-left: max(50px, env(safe-area-inset-left));
        padding-right: max(50px, env(safe-area-inset-right));
    }
    .auth-main {
        padding-right: max(24px, env(safe-area-inset-right));
        padding-bottom: max(44px, env(safe-area-inset-bottom));
        padding-left: max(24px, env(safe-area-inset-left));
    }
}

@media (pointer: coarse) {
    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="file"],
    .form-group select,
    .form-group textarea,
    .filter-bar input,
    .filter-bar select { min-height: 44px; font-size: 16px; }

    .btn,
    .mainnav a,
    .usermenu a,
    .auth-actions a,
    .pagination .page a,
    .pagination .page.current,
    .file-list .file-remove { min-height: 44px; }

    .btn,
    .mainnav a,
    .usermenu a,
    .auth-actions a,
    .pagination .page a,
    .pagination .page.current {
        display: inline-flex; align-items: center; justify-content: center;
    }
}

@media (max-width: 780px) {
    .topbar-inner {
        gap: 10px 12px;
        padding-left: 16px;
        padding-right: 16px;
    }
    .brand { flex: 1 1 auto; min-width: 0; }
    .mainnav {
        order: 3; width: 100%; margin-left: 0;
        display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px;
        scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .mainnav::-webkit-scrollbar { display: none; }
    .mainnav a {
        display: inline-flex; flex: 1 0 auto; align-items: center; justify-content: center;
        min-height: 44px; padding: 9px 12px;
    }
    .usermenu { margin-left: 0; }
    .user-name { display: none; }

    .container { margin-top: 16px; margin-bottom: 16px; padding: 0 16px; }
    .panel { padding: 18px; }
    .page-head { gap: 12px; margin-bottom: 16px; }

    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="file"],
    .form-group select,
    .form-group textarea,
    .filter-bar input,
    .filter-bar select { min-height: 44px; font-size: 16px; }

    .filter-bar .btn { min-height: 44px; }
    .timeline-head,
    .history-list li { flex-wrap: wrap; gap: 4px 12px; }
    .history-date { margin-left: auto; }

    .ticket-editor .toastui-editor-defaultUI-toolbar {
        overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    }
    .ticket-editor .toastui-editor-toolbar-group { flex: 0 0 auto; }
    .ticket-editor .ProseMirror,
    .ticket-editor .toastui-editor-contents { font-size: 16px; }

    @supports (padding: max(0px)) {
        .topbar-inner,
        .container {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
        .auth-brand-panel {
            padding-left: max(24px, env(safe-area-inset-left));
            padding-right: max(24px, env(safe-area-inset-right));
        }
        .auth-main {
            padding-right: max(18px, env(safe-area-inset-right));
            padding-bottom: max(30px, env(safe-area-inset-bottom));
            padding-left: max(18px, env(safe-area-inset-left));
        }
    }
}

@media (min-width: 641px) and (max-width: 780px) {
    .table-wrap { overflow: visible; margin: 0; padding: 0; }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td { display: block; width: 100%; }
    .responsive-table { min-width: 0; }
    .responsive-table thead { display: none; }
    .responsive-table tbody { display: grid; gap: 12px; }
    .responsive-table tr {
        padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px;
        background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.04);
    }
    .responsive-table td {
        display: grid; grid-template-columns: minmax(120px, 28%) minmax(0, 1fr);
        gap: 16px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line);
        text-align: right; overflow-wrap: anywhere;
    }
    .responsive-table td::before {
        content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 700;
        letter-spacing: .04em; text-align: left; text-transform: uppercase;
    }
    .responsive-table td:last-child { border-bottom: 0; }
    .responsive-table .truncate { max-width: none; white-space: normal; }
    .responsive-table .action-col { text-align: right; }
}

@media (max-width: 640px) {
    .auth-brand-panel {
        min-height: 0; justify-content: flex-start; padding-top: 18px; padding-bottom: 18px;
    }
    .auth-logo-chip { border-radius: 10px; padding: 6px 8px; }
    .auth-logo-chip img { height: 34px; }
    .auth-brand-copy,
    .auth-panel-foot { display: none; }
    .auth-main { justify-content: flex-start; padding-top: 22px; padding-bottom: 30px; }
    .auth-card { padding: 24px 20px 22px; }

    .page-head { flex-direction: column; align-items: stretch; }
    .page-head > .btn { width: 100%; }
    .dash-page .page-head h1,
    .create-page .page-head h1,
    .page-head h1 { font-size: 21px; overflow-wrap: anywhere; }
    .subtitle { overflow-wrap: anywhere; }

    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat-card { gap: 12px; padding: 14px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-card .stat-value { font-size: 24px; }
    .dash-panel { padding: 16px; }

    .filter-bar > input,
    .filter-bar > select,
    .filter-bar > .btn { flex: 1 1 100%; width: 100%; }

    .table-wrap { overflow: visible; margin: 0; padding: 0; }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td { display: block; width: 100%; }
    .responsive-table { min-width: 0; }
    .responsive-table thead { display: none; }
    .responsive-table tbody { display: grid; gap: 12px; }
    .responsive-table tr {
        padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px;
        background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.04);
    }
    .responsive-table td {
        display: grid; grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
        gap: 12px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line);
        text-align: right; overflow-wrap: anywhere;
    }
    .responsive-table td::before {
        content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 700;
        letter-spacing: .04em; text-align: left; text-transform: uppercase;
    }
    .responsive-table td:last-child { border-bottom: 0; }
    .responsive-table .truncate { max-width: none; white-space: normal; }
    .responsive-table .action-col { text-align: right; }
    .responsive-table .action-col .btn { min-height: 40px; }

    .rich-description table {
        display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
    .meta-list { grid-template-columns: minmax(88px, auto) minmax(0, 1fr); }
    .shot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .media-upload-grid { grid-template-columns: 1fr; }
    .media-attachment-meta { align-items: flex-start; flex-direction: column; }
    .form-actions { align-items: stretch; flex-direction: column; }
    .form-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
    .topbar-inner { padding-top: 8px; padding-bottom: 8px; }
    .brand-logo { height: 36px; }
    .brand-logo img { height: 26px; }
    .brand-text { font-size: 15px; }
    .brand-text small { display: none; }
    .usermenu .btn { padding-left: 12px; padding-right: 12px; }

    .container { padding-left: 12px; padding-right: 12px; }
    .panel { padding: 16px; border-radius: 10px; }
    .stat-card { align-items: flex-start; flex-direction: column; }
    .stat-copy { width: 100%; }
    .auth-card { padding: 22px 16px 20px; border-radius: 14px; }
    .auth-steps { gap: 7px; }
    .auth-steps .step-sep { flex-basis: 18px; }
    .form-group input.otp-input { padding: 16px 8px; font-size: 24px; letter-spacing: .28em; text-indent: .28em; }
    .auth-actions { align-items: stretch; flex-direction: column; }
    .auth-actions a { justify-content: center; min-height: 44px; text-align: center; }
    .shot-grid { grid-template-columns: 1fr; }

    @supports (padding: max(0px)) {
        .topbar-inner,
        .container {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
        }
    }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 600px) {
    .auth-shell { grid-template-columns: minmax(190px, 34%) minmax(0, 1fr); }
    .auth-brand-panel { justify-content: flex-start; padding: 20px; }
    .auth-brand-copy,
    .auth-panel-foot { display: none; }
    .auth-main { justify-content: flex-start; padding: 18px; }
}
