:root {
    --orange: #f58220;
    --orange-dark: #d96a13;
    --ink: #252a31;
    --muted: #6b7280;
    --line: #e5e7eb;
    --surface: #ffffff;
    --soft: #f4f6f8;
    --success: #2e7d32;
    --warning: #f6b73c;
    --danger: #c62828;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--soft);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
.primary-action {
    border: 0;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover,
.primary-action:hover {
    background: var(--orange-dark);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #fff7ed 0%, #f4f6f8 60%, #ffffff 100%);
}

.login-panel {
    width: min(420px, calc(100vw - 32px));
}

.login-card,
.panel,
.module-card,
.hero-band,
.metric-grid article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(37, 42, 49, 0.06);
}

.login-card {
    padding: 28px;
}

.login-brand,
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-brand span,
.brand span {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    font-weight: 900;
}

.login-card h1 {
    margin: 28px 0 18px;
}

.auth-note {
    margin: -6px 0 18px;
    color: var(--muted);
    line-height: 1.45;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    color: var(--muted);
    font-weight: 700;
}

.auth-links a {
    color: var(--orange-dark);
}

.auth-inline-form {
    margin-top: 12px;
}

.secondary-button {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.secondary-button:hover {
    background: #fff7ed;
    color: var(--orange-dark);
}

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

.sidebar-toggle,
.mobile-nav-button,
.sidebar-scrim,
.sidebar-close {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px;
    background: #1f2329;
    color: #fff;
    overflow: auto;
}

.sidebar-header {
    display: grid;
    gap: 12px;
}

.brand {
    padding: 4px 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-nav {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.sidebar-nav details {
    border-radius: 8px;
}

.sidebar-nav summary {
    cursor: pointer;
    padding: 10px;
    color: #f9fafb;
    font-weight: 800;
}

.sidebar-nav a {
    display: block;
    padding: 9px 10px;
    border-radius: 8px;
    color: #d1d5db;
}

.sidebar-nav a:hover,
.sidebar-nav .child-link:hover,
.sidebar-nav a.is-active {
    background: rgba(245, 130, 32, 0.16);
    color: #fff;
}

.sidebar-nav .child-link {
    margin-left: 12px;
    font-size: 14px;
}

.content-shell {
    min-width: 0;
    padding: 22px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar span,
.section-heading p,
.hero-band p {
    display: block;
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 800;
}

.topbar strong {
    font-size: 22px;
}

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

.topbar-actions a {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px 12px;
    font-weight: 700;
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.message {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #eef6ff;
    border: 1px solid #bfdbfe;
}

.message.success {
    background: #edf7ee;
    border-color: #b7dfba;
}

.message.error {
    background: #fff1f2;
    border-color: #fecdd3;
}

.message.warning {
    background: #fff7ed;
    border-color: #fed7aa;
}

.hero-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px;
    margin-bottom: 20px;
}

.hero-band h1,
.section-heading h1,
.section-heading h2,
.panel h1 {
    margin: 0;
}

.hero-band span,
.muted,
.module-card p,
td span {
    color: var(--muted);
}

.module-grid,
.metric-grid,
.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.module-card,
.panel,
.metric-grid article {
    padding: 18px;
}

.metric-grid strong {
    display: block;
    color: var(--orange-dark);
    font-size: 34px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

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

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

.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-stack label,
.form-grid label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.form-stack input,
.form-stack select,
.form-stack textarea,
.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.form-grid textarea {
    min-height: 96px;
}

small {
    color: var(--danger);
}

.form-help {
    color: var(--muted);
    font-size: 13px;
    font-style: normal;
    font-weight: 500;
    line-height: 1.4;
}

.table-wrap,
.permission-table-wrap {
    width: 100%;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: #374151;
    font-size: 13px;
}

.user-permission-list {
    display: grid;
    gap: 18px;
}

.permission-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.permission-card header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.permission-card header span {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.permission-table {
    min-width: 920px;
}

.permission-table .group-row td {
    background: #fff7ed;
    color: var(--orange-dark);
    font-weight: 900;
}

.check-cell {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
}

.check-cell input {
    position: absolute;
    opacity: 0;
}

.check-cell span {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
}

.check-cell input:checked + span {
    border-color: var(--orange);
    background: var(--orange);
    box-shadow: inset 0 0 0 4px #fff;
}

.secondary-action,
.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 9px 12px;
    font-weight: 800;
}

.table-action {
    padding: 6px 10px;
    font-size: 13px;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px 200px auto auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.filter-bar label,
.compact-form label {
    display: grid;
    gap: 6px;
    font-weight: 800;
}

.filter-bar input,
.filter-bar select,
.compact-form input,
.compact-form select,
.compact-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: #fff7ed;
    color: var(--orange-dark);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 900;
}

.doc-chip {
    background: #eef6ff;
    color: #1d4ed8;
}

.record-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(37, 42, 49, 0.06);
}

.record-hero p {
    margin: 0 0 4px;
    color: var(--orange-dark);
    text-transform: uppercase;
    font-weight: 900;
}

.record-hero h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
}

.record-hero span {
    color: var(--muted);
}

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

.process-hero {
    align-items: flex-start;
}

.requirement-list {
    display: grid;
    gap: 10px;
}

.requirement-list a {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.requirement-list a:hover {
    border-color: #fed7aa;
    background: #fff7ed;
}

.requirement-list span,
.process-step small {
    color: var(--muted);
}

.document-catalog {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.document-catalog li {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
}

.process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.process-step {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.process-step > span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #fff7ed;
    color: var(--orange-dark);
    font-weight: 900;
}

.process-step p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.process-step h3 {
    margin: 0 0 8px;
}

.process-step strong,
.process-step small {
    display: block;
    line-height: 1.45;
}

.process-step small {
    margin-top: 8px;
}

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

.record-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.record-list div {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

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

.record-list dd {
    margin: 0;
}

.text-block h3 {
    margin: 16px 0 6px;
    font-size: 14px;
}

.text-block h3:first-child {
    margin-top: 0;
}

.text-block p {
    margin: 0;
    color: var(--muted);
    white-space: pre-wrap;
}

.compact-form {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
    background: #fafafa;
}

.document-list,
.timeline {
    display: grid;
    gap: 10px;
}

.document-row,
.timeline article {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.document-row span,
.timeline span,
.timeline small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.document-row p,
.timeline p {
    margin: 6px 0 0;
    color: var(--muted);
    white-space: pre-wrap;
}

.timeline article {
    display: block;
    border-left: 4px solid var(--orange);
}

.wide-field,
.form-actions {
    grid-column: 1 / -1;
}

.document-gallery {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.document-gallery-stage {
    position: relative;
    min-height: 260px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111827;
    overflow: hidden;
}

.document-slide {
    display: none;
    width: 100%;
    height: 360px;
    align-items: center;
    justify-content: center;
}

.document-slide.is-active {
    display: flex;
}

.document-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111827;
}

.document-file-preview {
    display: grid;
    place-items: center;
    gap: 8px;
    color: #fff;
    padding: 24px;
    text-align: center;
}

.document-file-preview strong {
    display: grid;
    place-items: center;
    width: 86px;
    height: 86px;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    font-size: 24px;
}

.document-mosaic-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
}

.document-thumb {
    display: grid;
    gap: 6px;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 6px;
    min-height: 92px;
}

.document-thumb.is-active {
    border-color: var(--orange);
}

.document-thumb img {
    width: 100%;
    height: 54px;
    object-fit: cover;
    border-radius: 6px;
}

.document-thumb > span {
    display: grid;
    place-items: center;
    height: 54px;
    border-radius: 6px;
    background: #fff7ed;
    color: var(--orange-dark);
    font-weight: 900;
}

.document-thumb small {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-edit-row {
    align-items: flex-start;
}

.document-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.document-edit-grid label,
.document-row-actions {
    display: grid;
    gap: 6px;
}

.document-edit-grid input,
.document-edit-grid select,
.document-edit-grid textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
}

.document-edit-grid textarea {
    min-height: 74px;
}

.document-row-actions {
    min-width: 120px;
}

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

    .mobile-nav-button {
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 45;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--ink);
        padding: 9px 12px;
        box-shadow: 0 10px 30px rgba(37, 42, 49, 0.12);
        font-weight: 900;
    }

    .mobile-nav-button span,
    .mobile-nav-button span::before,
    .mobile-nav-button span::after {
        display: block;
        width: 16px;
        height: 2px;
        border-radius: 999px;
        background: var(--ink);
        content: "";
    }

    .mobile-nav-button span::before {
        transform: translateY(-6px);
    }

    .mobile-nav-button span::after {
        transform: translateY(4px);
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 50;
        display: block;
        pointer-events: none;
        background: rgba(17, 24, 39, 0);
        transition: background 160ms ease;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        width: min(84vw, 320px);
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: 18px 0 40px rgba(17, 24, 39, 0.24);
    }

    .sidebar-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle:checked ~ .sidebar-scrim {
        pointer-events: auto;
        background: rgba(17, 24, 39, 0.42);
    }

    .sidebar-close {
        display: inline-flex;
        justify-content: center;
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 8px;
        padding: 9px 12px;
        color: #f9fafb;
        font-weight: 800;
    }

    .hero-band,
    .topbar,
    .section-heading,
    .record-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .filter-bar,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .content-shell {
        padding: 72px 14px 18px;
    }

    .topbar-actions,
    .record-actions,
    .form-actions {
        width: 100%;
    }

    .topbar-actions a,
    .record-actions a,
    .form-actions a,
    .form-actions button {
        flex: 1 1 auto;
    }

    .metric-grid,
    .module-grid,
    .page-grid,
    .process-grid {
        grid-template-columns: 1fr;
    }

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

    .document-slide {
        height: 260px;
    }

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

    .document-row {
        display: grid;
    }
}
