:root {
    --bg: #edf2f6;
    --bg-strong: #dfe8ef;
    --surface: #ffffff;
    --surface-raised: #fbfdff;
    --surface-soft: #f3f7fa;
    --ink: #17212b;
    --text: #2f3b48;
    --muted: #6b7887;
    --line: #d6e0e8;
    --line-strong: #becbd6;
    --primary: #176b87;
    --primary-dark: #0f4e63;
    --primary-soft: #e1f2f6;
    --green: #2f855a;
    --green-soft: #e7f6ed;
    --amber: #b7791f;
    --amber-soft: #fff3d8;
    --red: #c2410c;
    --red-soft: #fff1ec;
    --blue: #315d9c;
    --violet: #6750a4;
    --sidebar: #101c26;
    --sidebar-soft: #172735;
    --shadow-sm: 0 5px 14px rgba(23, 33, 43, 0.08);
    --shadow: 0 16px 38px rgba(23, 33, 43, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 260px),
        linear-gradient(90deg, rgba(23, 107, 135, 0.08), rgba(47, 133, 90, 0.06) 42%, rgba(183, 121, 31, 0.05)),
        var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-dark);
}

button,
input,
textarea,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background:
        linear-gradient(180deg, rgba(23, 107, 135, 0.24), rgba(16, 28, 38, 0) 220px),
        var(--sidebar);
    color: #f8fafc;
}

.brand,
.user-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    min-height: 48px;
}

.brand strong,
.user-panel strong {
    display: block;
    color: inherit;
}

.brand small,
.user-panel small {
    display: block;
    color: #b8c4d0;
    font-size: 12px;
}

.brand-mark,
.avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f2c94c, #e38b29);
    color: #15202b;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(242, 201, 76, 0.22);
}

.avatar {
    background: linear-gradient(135deg, #dbeafe, #9bd6c8);
    box-shadow: none;
}

.user-panel {
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px 10px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #d7dee7;
    font-weight: 700;
}

.nav a::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.26);
}

.nav a:hover,
.nav a.active {
    border-color: rgba(255, 255, 255, 0.09);
    background: var(--sidebar-soft);
    color: #ffffff;
}

.nav a.active::before {
    background: #f2c94c;
    box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.14);
}

.logout-form {
    margin-top: auto;
}

.sidebar .btn-ghost {
    border-color: rgba(255, 255, 255, 0.14);
    color: #e5edf5;
}

.sidebar .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}

.main {
    min-width: 0;
    padding: 28px;
}

.topbar,
.detail-header,
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.topbar {
    align-items: center;
    min-height: 92px;
    margin-bottom: 20px;
    padding: 20px 22px;
    border: 1px solid rgba(214, 224, 232, 0.86);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78)),
        linear-gradient(135deg, rgba(23, 107, 135, 0.16), rgba(47, 133, 90, 0.12), rgba(183, 121, 31, 0.10));
    box-shadow: var(--shadow-sm);
}

.topbar h1,
.detail-header h2,
.panel h2 {
    margin: 0;
    color: var(--ink);
    line-height: 1.18;
}

.topbar h1 {
    font-size: 30px;
}

.panel h2,
.detail-header h2 {
    font-size: 20px;
}

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

.date-pill,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.date-pill {
    border-color: rgba(23, 107, 135, 0.18);
    background: rgba(255, 255, 255, 0.72);
    color: var(--primary-dark);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.badge {
    border-color: #cbd6df;
    background: #f4f7fa;
}

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

.badge-waiting {
    border-color: #efd08b;
    background: var(--amber-soft);
    color: var(--amber);
}

.badge-danger,
.alert-danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #9f1239;
}

.badge-muted {
    background: #eef2f7;
    color: var(--muted);
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.alert-success {
    border-color: #b9dfc8;
    background: var(--green-soft);
    color: #166534;
}

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

.stat-card,
.panel,
.location-card {
    border: 1px solid rgba(199, 212, 223, 0.9);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-card {
    position: relative;
    min-height: 132px;
    overflow: hidden;
    padding: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 253, 255, 0.98)),
        var(--surface);
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: var(--primary);
}

.stat-card:nth-child(2)::before {
    background: var(--green);
}

.stat-card:nth-child(3)::before {
    background: var(--amber);
}

.stat-card::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(23, 107, 135, 0.14);
    border-radius: 8px;
    background: rgba(23, 107, 135, 0.06);
}

.stat-card span {
    position: relative;
    z-index: 1;
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.stat-card strong {
    position: relative;
    z-index: 1;
    display: block;
    margin-top: 12px;
    color: var(--ink);
    font-size: 38px;
    line-height: 1;
}

.panel {
    padding: 20px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.94);
}

.panel:hover,
.location-card:hover,
.stat-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
}

.accent-panel {
    border-color: rgba(23, 107, 135, 0.28);
    background:
        linear-gradient(145deg, rgba(225, 242, 246, 0.92), rgba(255, 255, 255, 0.96) 56%),
        var(--surface);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 16px;
}

.narrow-panel {
    max-width: 920px;
}

.detail-header {
    align-items: center;
    margin-bottom: 16px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-sm);
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 16px 0 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #edf2f6;
}

.detail-list div:last-child {
    border-bottom: 0;
}

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

.detail-list dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.detail-list.compact div,
.detail-list.readable div {
    grid-template-columns: 1fr;
    gap: 4px;
}

.big-status {
    margin: 14px 0 8px;
    color: var(--primary-dark);
    font-size: 26px;
    font-weight: 800;
}

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

.empty {
    padding: 22px;
    color: var(--muted);
    text-align: center;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5ebf0;
    border-radius: 8px;
    background: #ffffff;
}

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

th,
td {
    padding: 14px 14px;
    border-bottom: 1px solid #e7edf2;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    color: #536170;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
    background: #f6f9fb;
}

tbody tr {
    background: #ffffff;
}

tbody tr:hover {
    background: #f7fbfd;
}

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

td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    text-align: center;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none;
}

.btn-primary {
    background: linear-gradient(180deg, #1e7896, var(--primary));
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(23, 107, 135, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #176b87, var(--primary-dark));
    color: #ffffff;
}

.btn-secondary {
    border-color: #afd1db;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.btn-ghost {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.66);
}

.btn-ghost:hover {
    border-color: var(--line-strong);
    background: #ffffff;
}

.btn-danger {
    background: linear-gradient(180deg, #d95324, var(--red));
    color: #ffffff;
}

.full {
    width: 100%;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 16px;
}

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

.form-grid .span-2 {
    grid-column: span 2;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.word-meter {
    display: block;
    margin-top: 6px;
    color: var(--red);
    font-size: 12px;
    font-weight: 800;
}

.word-meter.is-ready {
    color: var(--green);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cbd7e1;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(23, 107, 135, 0.72);
    box-shadow: 0 0 0 4px rgba(23, 107, 135, 0.12);
}

textarea {
    resize: vertical;
}

.form-actions,
.detail-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.progress-line {
    width: 170px;
    max-width: 100%;
    height: 9px;
    overflow: hidden;
    border-radius: 8px;
    background: #e2e8f0;
    box-shadow: inset 0 1px 2px rgba(23, 33, 43, 0.08);
}

.progress-line.large {
    width: 100%;
    height: 13px;
    margin: 18px 0;
}

.progress-line span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--green));
}

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

.workflow article {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, #ffffff, #f8fbfd);
    box-shadow: var(--shadow-sm);
}

.workflow strong,
.workflow small {
    overflow-wrap: anywhere;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

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

.location-card {
    display: grid;
    gap: 16px;
    overflow: hidden;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 252, 0.98)),
        var(--surface);
}

.location-card h3 {
    margin: 0;
    color: var(--ink);
}

.location-card p {
    margin: 8px 0 0;
    color: var(--muted);
}

.location-card dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.location-card dl div {
    padding: 12px;
    border: 1px solid #e4ebf1;
    border-radius: 8px;
    background: #ffffff;
}

.location-card dt,
.location-card dd {
    margin: 0;
}

.location-card dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.location-card dd {
    color: var(--ink);
    font-size: 22px;
    font-weight: 800;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(16, 28, 38, 0.94), rgba(23, 107, 135, 0.78) 46%, rgba(47, 133, 90, 0.62)),
        var(--sidebar);
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(320px, 430px);
    justify-content: center;
    width: min(520px, 100%);
}

.login-panel {
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
    padding: 30px;
}

.login-panel {
    align-self: stretch;
}

.login-brand {
    margin-bottom: 26px;
    color: var(--ink);
}

.login-brand small {
    color: var(--muted);
}

.nav-section {
    display: block;
    padding: 14px 14px 4px;
    color: rgba(255, 255, 255, 0.38);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.filter-tab:hover {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--text);
}

.filter-tab.active {
    border-color: rgba(23, 107, 135, 0.38);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 20px;
    background: #dde5ec;
    color: var(--muted);
    font-size: 11px;
}

.filter-tab.active .tab-count {
    background: rgba(23, 107, 135, 0.16);
    color: var(--primary-dark);
}

.tab-count--urgent {
    background: var(--amber-soft);
    color: var(--amber);
}

.filter-tab.active .tab-count--urgent {
    background: rgba(183, 121, 31, 0.18);
    color: var(--amber);
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

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

    .sidebar {
        position: static;
        height: auto;
    }

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

    .content-grid,
    .location-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .main,
    .sidebar,
    .login-panel {
        padding: 18px;
    }

    .topbar,
    .detail-header,
    .panel-head,
    .form-actions,
    .detail-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid,
    .workflow,
    .form-grid,
    .location-card dl {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: span 1;
    }

    .detail-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

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

}

@media print {
    body {
        background: #ffffff;
    }

    .sidebar,
    .topbar,
    .detail-actions,
    .btn,
    .alert {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .main {
        padding: 0;
    }

    .panel,
    .workflow article {
        box-shadow: none;
    }
}
