@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
:root {
    --navy: #172b51;
    --navy-soft: #243b66;
    --blue: #087fd0;
    --muted: #7b86a1;
    --coral: #ff514d;
    --paper: #ffffff;
    --line: #e0e3e9;
    --soft: #f7f8fa;
    --font-body: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    --font-mono: 'DM Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--navy); background: var(--paper); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(100% - 80px, 1580px); margin: 0 auto; padding: 28px 0 70px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.page-header h1 { margin: 0; font-size: clamp(34px, 3.5vw, 50px); font-weight: 800; letter-spacing: -.075em; line-height: 1; }
.page-header p { margin: 10px 0 0; color: var(--muted); font-size: 17px; line-height: 1.4; }

.view-mode { display: flex; gap: 13px; }
.mode-button, .layout-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid var(--line); color: var(--muted); background: #fff; font-weight: 600; transition: color .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease; }
.mode-button { min-height: 48px; padding: 0 20px; border-radius: 7px; font-size: 14px; white-space: nowrap; }
.mode-button:hover, .mode-button:focus-visible, .layout-button:hover, .layout-button:focus-visible { border-color: var(--navy); color: var(--navy); }
.mode-button.is-active { border-color: var(--navy); color: #fff; background: var(--navy); box-shadow: 0 6px 12px rgb(23 43 81 / 12%); }
.mode-button svg, .layout-button svg, .search-box svg, .sort-box svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.mode-button svg path { fill: currentColor; stroke: none; }

.category-tabs { display: flex; gap: 10px; margin-top: 35px; overflow-x: auto; padding: 0 0 7px; scrollbar-width: thin; }
.category-tab { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 18px; min-height: 64px; padding: 0 20px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; transition: color .2s ease, background .2s ease, border-color .2s ease; }
.category-tab:hover, .category-tab:focus-visible { border-color: var(--navy-soft); color: var(--navy); }
.category-tab.is-active { border-color: var(--navy); color: #fff; background: var(--navy); }
.tab-number { color: var(--coral); font: 13px var(--font-mono); font-weight: 500; }
.category-tab.is-active .tab-number { color: #ffd21c; }

.ticket-section { margin-top: 14px; }
.ticket-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 84px; padding: 19px 0; border-top: 1px solid #edf0f3; }
.ticket-toolbar > p { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.035em; }
.toolbar-actions { display: flex; align-items: center; gap: 14px; }
.search-box, .sort-box { display: flex; align-items: center; gap: 12px; height: 52px; border: 1px solid var(--line); border-radius: 7px; color: #8d96aa; background: #fff; }
.search-box { width: 280px; padding: 0 14px; }
.sort-box { width: 230px; padding: 0 14px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--navy); background: transparent; font-size: 14px; }
.search-box input::placeholder { color: #8d96aa; }
.sort-box select { width: 100%; border: 0; outline: 0; color: var(--navy); background: #fff; font-size: 14px; appearance: auto; }
.layout-switcher { display: flex; gap: 8px; }
.layout-button { width: 52px; height: 52px; border-radius: 7px; }
.layout-button svg path { stroke-width: 1.6; }
.layout-button.is-active { border-color: var(--navy); color: #fff; background: var(--navy); }

.ticket-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ticket-card { min-width: 0; padding: 16px 16px 17px; border: 1px solid #e7e9ee; border-radius: 15px; background: #fff; box-shadow: 0 7px 20px rgb(31 52 85 / 6%); transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.ticket-card:hover { border-color: #cbd1dd; box-shadow: 0 14px 30px rgb(31 52 85 / 11%); transform: translateY(-2px); }
.ticket-card.is-flagged { border-color: var(--coral); }
.ticket-preview { position: relative; aspect-ratio: 1.18; overflow: hidden; border-radius: 9px; background: #eff1f4; }
.ticket-preview iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.preview-label { position: absolute; right: 9px; bottom: 9px; padding: 7px 9px; color: #fff; border-radius: 4px; background: rgb(23 43 81 / 87%); font: 11px var(--font-mono); pointer-events: none; }
.ticket-meta { padding: 20px 3px 0; }
.ticket-meta-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ticket-category { margin: 0 0 8px; overflow: hidden; color: var(--blue); font: 12px var(--font-mono); letter-spacing: .02em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.ticket-number { margin: 0; overflow: hidden; color: var(--navy); font: 21px var(--font-mono); font-weight: 500; letter-spacing: -.08em; text-overflow: ellipsis; white-space: nowrap; }
.flag-pill { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; min-height: 31px; padding: 0 9px; border: 1px solid #cfe4fa; border-radius: 5px; color: var(--blue); font: 12px var(--font-mono); text-transform: uppercase; }
.is-flagged .flag-pill { border-color: #ffc6c0; color: var(--coral); background: #fff5f3; }
.flag-dot { width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.is-flagged .flag-dot { background: var(--coral); }
.ticket-subline { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 37px; margin-top: 10px; color: var(--muted); font: 12px var(--font-mono); }
.ticket-updated { color: var(--coral); text-align: right; }
.ticket-actions { display: flex; gap: 9px; margin-top: 10px; }
.ticket-action { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; border: 1px solid var(--navy); border-radius: 6px; font-size: 15px; font-weight: 700; text-decoration: none; transition: color .2s ease, background .2s ease, border-color .2s ease; }
.ticket-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.download-action { flex: 1; color: #fff; background: var(--navy); }
.download-action:hover, .download-action:focus-visible { color: var(--navy); background: #fff; }
.flag-action { width: 64px; color: var(--navy); background: #fff; }
.flag-action:hover, .flag-action:focus-visible, .flag-action[aria-pressed="true"] { color: #fff; border-color: var(--navy); background: var(--navy); }
.ticket-card.is-saving { opacity: .55; pointer-events: none; }

.ticket-grid.is-list { grid-template-columns: 1fr; }
.ticket-grid.is-list .ticket-card { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 26px; }
.ticket-grid.is-list .ticket-meta { align-self: center; padding: 0; }
.ticket-grid.is-list .ticket-actions { max-width: 420px; }
.load-sentinel { height: 2px; }
.loading-state, .end-state, .empty-state { align-items: center; justify-content: center; min-height: 120px; color: var(--muted); }
.loading-state { display: flex; gap: 10px; font: 12px var(--font-mono); }
.loader { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--coral); border-radius: 50%; animation: spin .7s linear infinite; }
.end-state { display: flex; font: 12px var(--font-mono); }
.empty-state { display: flex; flex-direction: column; border-top: 1px solid var(--line); text-align: center; }
.empty-state h2 { margin: 0; font-size: 20px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
    .page-shell { width: min(100% - 48px, 1000px); }
    .ticket-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 820px) {
    .page-shell { width: min(100% - 32px, 680px); padding-top: 22px; }
    .page-header { display: block; }
    .page-header p { font-size: 14px; }
    .view-mode { margin-top: 22px; }
    .mode-button { flex: 1; padding: 0 12px; font-size: 12px; }
    .category-tabs { margin-top: 27px; }
    .ticket-toolbar { align-items: stretch; flex-direction: column; gap: 14px; padding: 20px 0; }
    .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr auto; justify-content: stretch; }
    .search-box, .sort-box { width: auto; }
    .search-box { grid-column: 1 / -1; }
    .ticket-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .ticket-card { padding: 11px 11px 12px; border-radius: 11px; }
    .ticket-meta { padding-top: 14px; }
    .ticket-category { font-size: 10px; }
    .ticket-number { font-size: 16px; }
    .flag-pill { min-height: 26px; padding: 0 6px; font-size: 10px; }
    .ticket-subline { display: block; font-size: 10px; line-height: 1.7; }
    .ticket-updated { text-align: left; }
    .ticket-action { min-height: 45px; font-size: 12px; }
    .ticket-action svg { width: 17px; height: 17px; }
    .flag-action { width: 48px; }
    .ticket-grid.is-list .ticket-card { display: block; }
    .ticket-grid.is-list .ticket-meta { padding-top: 14px; }
}

@media (max-width: 480px) {
    .ticket-grid { grid-template-columns: 1fr; }
    .ticket-preview { aspect-ratio: 1.3; }
    .toolbar-actions { grid-template-columns: 1fr auto; }
    .sort-box { grid-column: 1 / -1; }
    .layout-switcher { grid-column: 2; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
