:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
    --bg: #eef2f7;
    --sidebar: #111827;
    --sidebar-muted: #cbd5e1;
    --surface: #ffffff;
    --surface-strong: #f1f5f9;
    --line: #d9e2ef;
    --text: #172033;
    --muted: #64748b;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #047857;
    --green-bg: #ecfdf5;
    --amber: #b45309;
    --amber-bg: #fff7ed;
    --red: #b91c1c;
    --red-bg: #fef2f2;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

button,
.button,
nav a {
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #172033;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 13px;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
}

button:hover,
.button:hover,
nav a:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    text-decoration: none;
}

button:focus-visible,
.button:focus-visible,
nav a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

button[type="submit"],
.button.primary {
    border-color: var(--blue);
    background: var(--blue);
    color: #ffffff;
}

button[type="submit"]:hover,
.button.primary:hover {
    border-color: var(--blue-dark);
    background: var(--blue-dark);
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    background: linear-gradient(180deg, #f5f7fb 0%, var(--bg) 100%);
}

.app-shell.public {
    grid-template-columns: 1fr;
}

header {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--sidebar);
    color: #ffffff;
    padding: 22px 16px;
}

.public header {
    display: none;
}

.brand {
    display: grid;
    gap: 4px;
}

.brand strong {
    font-size: 18px;
    line-height: 1.2;
}

.brand span,
.account span {
    color: var(--sidebar-muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.account {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 12px;
}

nav {
    display: grid;
    gap: 8px;
    align-content: start;
}

nav a,
nav button {
    justify-content: flex-start;
    width: 100%;
    text-align: left;
}

nav form {
    margin: 8px 0 0;
}

main {
    min-width: 0;
    width: 100%;
    max-width: 1280px;
    padding: 28px;
}

.public main {
    display: grid;
    align-content: center;
    min-height: 100vh;
    max-width: 760px;
    margin: 0 auto;
}

.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.25;
}

h2 {
    margin: 28px 0 12px;
    font-size: 18px;
    line-height: 1.3;
}

h3 {
    margin: 0 0 10px;
    font-size: 16px;
    line-height: 1.3;
}

p {
    margin: 0 0 12px;
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.narrow {
    max-width: 720px;
}

.notice,
.error,
.empty {
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #7c2d12;
    padding: 14px 16px;
}

.error {
    border-color: #fecaca;
    background: var(--red-bg);
    color: var(--red);
}

.empty {
    border-color: var(--line);
    background: var(--surface);
    color: var(--muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stats article,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stats article {
    display: grid;
    gap: 5px;
    min-height: 104px;
    padding: 16px;
}

.stats span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stats strong {
    font-size: 28px;
    line-height: 1.1;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.panel {
    padding: 18px;
}

.panel ul {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.panel li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.panel li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.filters,
.actions,
.search {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 16px;
}

.filters label,
.actions label,
.search label {
    min-width: 180px;
}

.actions form,
.search form {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.table-wrap {
    overflow-x: auto;
    margin: 12px 0 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.table-wrap table {
    margin: 0;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-strong);
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

tbody tr:nth-child(even) {
    background: #fbfdff;
}

tbody tr:hover {
    background: #eff6ff;
}

td {
    overflow-wrap: anywhere;
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.badge.ok {
    border-color: #bbf7d0;
    background: var(--green-bg);
    color: var(--green);
}

.badge.warn {
    border-color: #fed7aa;
    background: var(--amber-bg);
    color: var(--amber);
}

.badge.danger {
    border-color: #fecaca;
    background: var(--red-bg);
    color: var(--red);
}

dl {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0 0 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

dt {
    color: var(--muted);
    font-weight: 800;
}

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0 24px;
}

pre {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px;
}

iframe {
    width: 100%;
    min-height: 70vh;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.transcript-viewer {
    display: grid;
    gap: 14px;
}

.viewer-toolbar {
    display: grid;
    gap: 12px;
}

.viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ticket-frame {
    min-height: calc(100vh - 190px);
    box-shadow: var(--shadow);
}

@media (max-width: 1020px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    header {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    nav form {
        grid-column: 1 / -1;
        margin-top: 0;
    }

    main {
        padding: 18px;
    }

    .page-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .filters,
    .actions,
    .search,
    .actions form,
    .search form {
        display: grid;
    }

    .filters label,
    .actions label,
    .search label {
        min-width: 0;
    }

    dl {
        grid-template-columns: 1fr;
    }

    .ticket-frame {
        min-height: 72vh;
    }
}

@media (max-width: 560px) {
    nav {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 24px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .panel,
    .stats article,
    dl {
        padding: 14px;
    }

    th,
    td {
        padding: 10px;
    }
}
