:root {
    --bg: #f4efe7;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: rgba(255, 255, 255, 0.94);
    --surface-dark: #14212b;
    --text: #1e2430;
    --text-soft: #6b7280;
    --accent: #cb4b16;
    --accent-strong: #8f2500;
    --success: #1b7f61;
    --danger: #b93833;
    --shadow-xl: 0 24px 70px rgba(20, 33, 43, 0.14);
    --shadow-md: 0 16px 40px rgba(20, 33, 43, 0.08);
    --radius-xl: 28px;
    --radius-lg: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Aptos", "Trebuchet MS", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(203, 75, 22, 0.16), transparent 30%),
        radial-gradient(circle at top right, rgba(11, 92, 171, 0.14), transparent 32%),
        linear-gradient(180deg, #fbf8f2 0%, #f1ece3 100%);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 22px;
    background: linear-gradient(180deg, rgba(20, 33, 43, 0.95), rgba(15, 23, 32, 0.98));
    color: #f5f7fb;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(203, 75, 22, 0.28), rgba(255, 255, 255, 0.05));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-kicker,
.sidebar-label,
.eyebrow,
.preview-item span {
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.brand-title { font-size: 1.55rem; font-weight: 700; }
.brand-copy,
.muted,
.stat-copy,
.section-header p,
.hero-copy p,
.footer-note,
.hint { color: var(--text-soft); line-height: 1.6; }
.sidebar .brand-copy,
.sidebar .sidebar-label,
.sidebar .nav-note,
.sidebar .brand-kicker { color: rgba(255, 255, 255, 0.74); }
.sidebar-section { margin-top: 28px; }
.nav-list { display: grid; gap: 10px; }
.nav-link,
.nav-note {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}
.nav-link { color: rgba(255, 255, 255, 0.88); transition: transform 180ms ease, background-color 180ms ease; }
.nav-link:hover,
.nav-link.is-active { transform: translateX(3px); background: rgba(255, 255, 255, 0.12); }
.nav-note { display: block; }

.app { padding: 34px; }
.hero,
.card,
.preview-sheet {
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 248, 240, 0.94));
    box-shadow: var(--shadow-xl);
}
.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 32px;
}
.hero-copy h1,
.hero-copy h2 { margin: 0; font-size: clamp(2rem, 2.8vw, 3.1rem); line-height: 1.05; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}
.button-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.button-secondary { color: var(--text); background: rgba(255, 255, 255, 0.88); }
.button-danger-soft {
    color: var(--danger);
    background: rgba(185, 56, 51, 0.1);
    border: 1px solid rgba(185, 56, 51, 0.16);
}
.badge,
.pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
}
.badge { background: rgba(27, 127, 97, 0.12); color: var(--success); }
.pill { background: rgba(20, 33, 43, 0.06); }

.grid,
.stack,
.timeline,
.info-list,
.errors { display: grid; gap: 18px; }
.grid { margin-top: 26px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { padding: 24px; box-shadow: var(--shadow-md); }
.stat-value { margin-top: 14px; font-size: 2rem; font-weight: 700; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.section-header h3,
.card h3,
.card h4,
.preview-header h3 { margin: 0; }
.timeline-item,
.info-list li {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(20, 33, 43, 0.06);
}
.info-list { list-style: none; padding: 0; margin: 0; }

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
    gap: 22px;
    margin-top: 26px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.field { display: grid; gap: 8px; }
.field-full { grid-column: 1 / -1; }
.field[hidden] { display: none; }
.field label { font-size: 0.94rem; font-weight: 700; }
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border: 1px solid rgba(20, 33, 43, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(203, 75, 22, 0.46);
    box-shadow: 0 0 0 4px rgba(203, 75, 22, 0.12);
}
.brand-guidance {
    display: grid;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid rgba(20, 33, 43, 0.08);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(244, 239, 231, 0.96));
}

.brand-guidance strong {
    font-size: 0.98rem;
}

.brand-extra-card {
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(11, 92, 171, 0.14);
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(11, 92, 171, 0.08), rgba(255, 255, 255, 0.96));
}

.brand-extra-header {
    display: grid;
    gap: 6px;
}

.autocomplete-shell {
    position: relative;
}

.autocomplete-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    display: grid;
    gap: 6px;
    max-height: 280px;
    padding: 10px;
    overflow-y: auto;
    border: 1px solid rgba(20, 33, 43, 0.08);
    border-radius: 18px;
    background: rgba(255, 252, 248, 0.98);
    box-shadow: 0 22px 40px rgba(20, 33, 43, 0.12);
    backdrop-filter: blur(16px);
}

.autocomplete-panel[hidden],
.autocomplete-status[hidden] {
    display: none;
}

.autocomplete-option {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
    background: rgba(203, 75, 22, 0.12);
    transform: translateY(-1px);
}

.autocomplete-option-label {
    font-weight: 700;
}

.autocomplete-option-meta,
.autocomplete-empty,
.autocomplete-status {
    color: var(--text-soft);
    line-height: 1.5;
}

.autocomplete-option-meta {
    font-size: 0.9rem;
}

.autocomplete-empty {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(20, 33, 43, 0.04);
}

.autocomplete-status {
    margin-top: 8px;
    font-size: 0.9rem;
}

.error {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(185, 56, 51, 0.1);
    color: var(--danger);
    border: 1px solid rgba(185, 56, 51, 0.12);
}

.preview-sheet { overflow: hidden; background: #fffdfa; }
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(20, 33, 43, 0.96), rgba(44, 57, 72, 0.95));
    color: #f8fafc;
}
.preview-body { display: grid; gap: 22px; padding: 24px; }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.preview-item { padding-bottom: 12px; border-bottom: 1px dashed rgba(20, 33, 43, 0.12); }
.preview-legal {
    padding: 20px;
    border-radius: 20px;
    background: rgba(244, 239, 231, 0.7);
    color: #334155;
    line-height: 1.65;
}
.preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px 24px;
}
.footer-note { margin-top: 28px; text-align: center; }

@media (max-width: 1180px) {
    .shell,
    .form-layout,
    .grid-3,
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .app { padding: 22px; }
}

@media (max-width: 720px) {
    .hero,
    .section-header,
    .preview-header,
    .preview-actions { flex-direction: column; align-items: flex-start; }
    .form-grid,
    .preview-grid { grid-template-columns: 1fr; }
    .app { padding: 16px; }
}

.notice {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid transparent;
}

.notice-success {
    background: rgba(27, 127, 97, 0.12);
    border-color: rgba(27, 127, 97, 0.16);
    color: var(--success);
}

.notice-danger {
    background: rgba(185, 56, 51, 0.1);
    border-color: rgba(185, 56, 51, 0.16);
    color: var(--danger);
}

.notice-warning {
    background: rgba(203, 75, 22, 0.1);
    border-color: rgba(203, 75, 22, 0.16);
    color: var(--accent-strong);
}

.table-card {
    margin-top: 26px;
}

.table-wrap {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(20, 33, 43, 0.08);
    text-align: left;
    vertical-align: top;
}

.table th {
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-issued {
    background: rgba(27, 127, 97, 0.12);
    color: var(--success);
}

.status-cancelled {
    background: rgba(185, 56, 51, 0.1);
    color: var(--danger);
}

.empty-state {
    padding: 28px;
    border-radius: 18px;
    background: rgba(20, 33, 43, 0.05);
    color: var(--text-soft);
    text-align: center;
}

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

.detail-item {
    padding: 16px;
    border-radius: 18px;
    background: rgba(20, 33, 43, 0.04);
    line-height: 1.55;
}

.detail-item span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.detail-item-full {
    grid-column: 1 / -1;
}

.document-sheet {
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(250,247,241,0.98));
}

.mono {
    font-family: Consolas, 'Courier New', monospace;
}

@media (max-width: 720px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar,
    .footer-note,
    .hero-actions,
    .no-print,
    .notice {
        display: none !important;
    }

    .shell,
    .app,
    .form-layout {
        display: block;
        padding: 0;
        margin: 0;
    }

    .hero,
    .card,
    .document-sheet {
        box-shadow: none;
        border: 0;
        background: #ffffff;
    }
}
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-shell {
    width: min(100%, 520px);
    padding: 24px;
}

.auth-card {
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 240, 0.98));
    box-shadow: var(--shadow-xl);
}

.auth-brand {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-brand h1 {
    margin: 0;
    font-size: 2.2rem;
}

.auth-brand p,
.auth-note {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
}

.auth-form {
    margin-top: 16px;
}

.brand-logo {
    width: 160px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.auth-logo {
    width: 190px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

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

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

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

.autocomplete-card {
    display: grid;
    gap: 18px;
}

.autocomplete-list {
    display: grid;
    gap: 14px;
}

.autocomplete-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(247, 241, 233, 0.95));
    border: 1px solid rgba(20, 33, 43, 0.08);
}

.autocomplete-copy {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.autocomplete-headline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.autocomplete-chip,
.autocomplete-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.autocomplete-chip {
    background: rgba(20, 33, 43, 0.06);
    color: var(--text);
}

.autocomplete-count {
    background: rgba(203, 75, 22, 0.12);
    color: var(--accent-strong);
}

.autocomplete-meta,
.autocomplete-stamp {
    color: var(--text-soft);
    line-height: 1.55;
}

.autocomplete-stamp {
    font-size: 0.92rem;
}

.autocomplete-actions {
    flex-shrink: 0;
}

.audit-table td {
    min-width: 120px;
}

.audit-date strong,
.audit-event strong {
    display: block;
}

.audit-actor,
.audit-event,
.audit-detail-list,
.audit-dialog-head,
.audit-pagination,
.audit-footer {
    display: flex;
    gap: 10px;
}

.audit-actor,
.audit-event {
    flex-direction: column;
    align-items: flex-start;
}

.audit-chip,
.audit-detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(20, 33, 43, 0.06);
    color: var(--text);
    font-size: 0.86rem;
    line-height: 1.4;
}

.audit-detail-list {
    flex-wrap: wrap;
}

.audit-raw-button {
    min-height: 40px;
    padding: 0 14px;
}

.audit-pagination,
.audit-footer {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.audit-footer {
    margin-top: 18px;
}

.audit-dialog {
    width: min(920px, calc(100vw - 32px));
    margin: 5vh auto;
    padding: 0;
    border: 0;
    border-radius: 28px;
    box-shadow: 0 28px 80px rgba(20, 33, 43, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(247, 241, 233, 0.98));
}

.audit-dialog[open] {
    display: block;
}

.audit-dialog::backdrop {
    background: rgba(20, 33, 43, 0.46);
    backdrop-filter: blur(4px);
}

.audit-dialog-head {
    align-items: flex-start;
    justify-content: space-between;
    padding: 22px 24px 0;
}

.audit-raw-content {
    margin: 0;
    padding: 20px 24px 24px;
    overflow-x: auto;
    color: #d8e1ec;
    font-size: 0.92rem;
    line-height: 1.6;
    background: #14212b;
    border-radius: 0 0 28px 28px;
}

@media (max-width: 1180px) {
    .autocomplete-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .autocomplete-row {
        flex-direction: column;
        align-items: stretch;
    }

    .autocomplete-actions .button {
        width: 100%;
    }

    .audit-dialog-head,
    .audit-footer {
        flex-direction: column;
        align-items: stretch;
    }
}
