:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-alt: #eef4fa;
    --text: #152437;
    --muted: #66778a;
    --line: #dfe7ef;
    --primary: #0e6474;
    --primary-dark: #094b58;
    --primary-soft: #dff2f5;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --warning: #9a6700;
    --warning-soft: #fff1c2;
    --success: #16794f;
    --success-soft: #dff6e9;
    --blue: #2459a9;
    --blue-soft: #e2ebfa;
    --shadow: 0 14px 40px rgba(20, 43, 67, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar-inner { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--primary); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .08em; }
.brand small { color: var(--muted); }
.brand-light { color: white; }
.brand-light small { color: rgba(255,255,255,.68); }
.user-nav { display: flex; align-items: center; gap: 18px; }
.user-name { text-align: right; }
.user-name strong, .user-name small { display: block; }
.user-name small { color: var(--muted); }

.page-content { padding: 38px 0 60px; }
.page-heading, .detail-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; margin-bottom: 10px; letter-spacing: -.03em; }
h2 { font-size: 20px; margin-bottom: 4px; }
.page-heading p, .detail-header p, .panel-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { display: inline-block; margin-bottom: 8px; color: var(--primary); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }

.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 20px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: 14px; }
.stat-card strong { margin-top: 8px; font-size: 32px; }
.stat-card-warning { border-color: #efcf72; background: #fffaf0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.filters { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, 1fr) auto; gap: 14px; align-items: end; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
input, select { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid #cad6e2; border-radius: 10px; background: white; color: var(--text); outline: none; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,100,116,.13); }
.filter-actions { display: flex; gap: 8px; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: white; color: var(--text); border-color: var(--line); }
.button-small { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.button-full { width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: #f9fbfd; }
.table-action { width: 46px; text-align: right; }
.icon-link { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--surface-alt); text-decoration: none; font-size: 21px; color: var(--primary); }
.status { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.status-large { min-height: 36px; padding: 7px 14px; }
.status-processing { color: var(--blue); background: var(--blue-soft); }
.status-sent { color: #6f45a8; background: #eee5fa; }
.status-completed { color: var(--success); background: var(--success-soft); }
.status-needs-info { color: var(--warning); background: var(--warning-soft); }
.status-cancelled { color: var(--danger); background: var(--danger-soft); }
.status-default { color: var(--muted); background: #edf1f5; }

.alert { padding: 13px 15px; margin-bottom: 18px; border-radius: 10px; }
.alert-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f6b8b3; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 18px; }
.back-link { display: inline-flex; margin-bottom: 18px; color: var(--primary); font-weight: 750; text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.data-list { margin: 0; }
.data-list > div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.data-list dt { color: var(--muted); }
.data-list dd { margin: 0; font-weight: 650; }
.note-text { margin-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; padding-bottom: 24px; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 14px; width: 2px; height: calc(100% - 2px); background: var(--line); }
.timeline-dot { width: 14px; height: 14px; margin-top: 5px; border-radius: 50%; background: var(--primary); border: 3px solid var(--primary-soft); z-index: 1; }
.timeline strong, .timeline time { display: block; }
.timeline time { color: var(--muted); font-size: 14px; margin-top: 3px; }
.footer { color: var(--muted); font-size: 13px; padding: 22px 0 30px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9f0f6; }
.login-shell { width: min(1040px, 100%); min-height: 650px; display: grid; grid-template-columns: 1.08fr .92fr; border-radius: 24px; overflow: hidden; box-shadow: 0 24px 70px rgba(15,45,70,.18); }
.login-panel { padding: clamp(32px, 5vw, 62px); }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; color: white; background: linear-gradient(145deg, #083f4b, #0e6474 62%, #148597); }
.login-intro h1 { max-width: 570px; }
.login-intro p { max-width: 530px; color: rgba(255,255,255,.76); font-size: 18px; }
.login-intro .eyebrow { color: #a8e7ef; }
.feature-list { display: grid; gap: 11px; padding-left: 20px; margin: 0; color: rgba(255,255,255,.88); }
.login-form-panel { display: grid; place-items: center; background: white; }
.login-form { width: min(390px, 100%); display: grid; gap: 18px; }
.form-header { margin-bottom: 8px; }
.form-header h2 { font-size: 30px; }
.form-header p { color: var(--muted); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 88px; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--primary); font-size: 13px; font-weight: 800; cursor: pointer; }
.demo-box { display: grid; gap: 3px; padding: 13px; border-radius: 10px; background: var(--surface-alt); color: var(--muted); font-size: 13px; }
.demo-box strong { color: var(--text); }

@media (max-width: 980px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .filters { grid-template-columns: repeat(2, 1fr); }
    .field-search { grid-column: 1 / -1; }
    .filter-actions { grid-column: 1 / -1; }
    .login-shell { grid-template-columns: 1fr; }
    .login-intro { min-height: 390px; }
}

@media (max-width: 700px) {
    .container { width: min(100% - 22px, 1180px); }
    .topbar-inner { min-height: 68px; }
    .user-name { display: none; }
    .page-content { padding-top: 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; gap: 0; }
    .page-heading, .detail-header { align-items: flex-start; flex-direction: column; }
    .filters { grid-template-columns: 1fr; }
    .field-search, .filter-actions { grid-column: auto; }
    .filter-actions .button { flex: 1; }
    .panel { padding: 16px; }
    .table-panel { padding: 12px; }
    .table-wrap { overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { display: none; }
    tbody { display: grid; gap: 12px; }
    tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
    td { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 0; border: 0; }
    td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
    .table-action { position: absolute; right: 25px; width: auto; }
    .table-action::before { display: none; }
    .data-list > div { grid-template-columns: 110px 1fr; }
    .login-page { padding: 0; }
    .login-shell { min-height: 100vh; border-radius: 0; }
    .login-intro { min-height: 330px; }
}
