/* Citizen Pathway — readable, high-contrast layout. No framework. */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --ink: #0f172a;
    --muted: #475569;
    --line: #d5deea;
    --paper: #ffffff;
    --wash: #e7eef6;
    --brand: #1d4ed8;
    --brand-soft: #dbeafe;
    --ok: #047857;
    --ok-soft: #d1fae5;
    --warn: #92400e;
    --warn-soft: #fef3c7;
    --danger: #b91c1c;
    --tile-time: #dbeafe;
    --tile-fee: #d1fae5;
    --tile-check: #ccfbf1;
    --tile-code: #e2e8f0;
    --tile-web: #e0e7ff;
    --tile-phone: #ffedd5;
    --tile-pin: #e0f2fe;
    --tile-person: #ede9fe;
    --tile-flag: #fae8ff;
    --tile-warn: #ffedd5;
    --tile-paper: #e2e8f0;
}

html {
    font-size: 16px;
    background: var(--wash);
}

body {
    background: var(--wash);
    color: var(--ink);
    font-family: "Nirmala UI", "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: var(--brand);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 100;
}
.skip-link:focus {
    left: 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.status-banner {
    background: #fef3c7;
    color: #78350f;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.875rem;
    border-bottom: 1px solid #fde68a;
}
.status-banner.is-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 10px 16px;
    flex-shrink: 0;
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
    align-items: center;
    gap: 12px 20px;
}

.brand {
    min-width: 0;
}
header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--brand);
    letter-spacing: -0.02em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
header p {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.control-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
    gap: 8px 10px;
    min-width: 0;
}
.control-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.control-group label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.control-group select {
    background: #f1f5f9;
    border: 1px solid var(--line);
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 7px 8px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    cursor: pointer;
    font-family: inherit;
    color: var(--ink);
    text-overflow: ellipsis;
}
.control-group select:focus {
    outline: 2px solid #93c5fd;
    border-color: #3b82f6;
}

@media (max-width: 860px) {
    .header-container {
        grid-template-columns: 1fr;
    }
    .control-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

main {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 18px 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    flex: 1;
}
@media (min-width: 1024px) {
    main {
        grid-template-columns: 1.15fr 0.85fr;
        align-items: start;
    }
    .helper-brief { grid-column: 1 / -1; }
}

.card-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

#badgeService {
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 0.8rem;
    font-weight: 650;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #dbeafe;
}
#txtTargetFocus {
    font-size: 0.8rem;
    color: #94a3b8;
}

.helper-brief {
    background: #edf4ff;
    border-color: #bfdbfe;
}
.helper-brief-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.helper-brief-head h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}
.ref-hint {
    font-size: 0.75rem;
    color: #94a3b8;
}
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.25rem, 1fr));
    gap: 10px;
}
.kpi {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: var(--tile-code);
    border: 1px solid var(--line);
    text-align: start;
    font: inherit;
    color: inherit;
    text-decoration: none;
    cursor: default;
    min-height: 4.5rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    appearance: none;
}
.kpi.tip,
.kpi[data-tip] { cursor: help; }
a.kpi { cursor: pointer; }
.kpi:hover { filter: brightness(0.98); }
.kpi svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--brand);
}
.kpi-time { background: var(--tile-time); border-color: #93c5fd; }
.kpi-fee { background: var(--tile-fee); border-color: #6ee7b7; }
.kpi-check { background: var(--tile-check); border-color: #5eead4; }
.kpi-code { background: var(--tile-code); border-color: #cbd5e1; }
.kpi-web { background: var(--tile-web); border-color: #a5b4fc; }
.kpi-phone { background: var(--tile-phone); border-color: #fdba74; }
.kpi-fee svg { color: #047857; }
.kpi-warn svg, .kpi-phone svg { color: #c2410c; }
.kpi-copy { min-width: 0; }
.kpi-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 2px;
}
.kpi-value {
    font-size: 0.95rem;
    font-weight: 750;
    color: var(--ink);
    line-height: 1.3;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.chip,
.mini-value,
.pro-tip,
.tip {
    font-family: inherit;
}
.chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 650;
    cursor: help;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    color: var(--ink);
}
.chip .tip-short {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 16rem;
}
.chip-branch { background: var(--brand-soft); border-color: #bfdbfe; color: #1e40af; }
.chip-reject { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.chip-note { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }

.tip-mark {
    display: inline-grid;
    place-items: center;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.62rem;
    font-weight: 800;
    font-style: italic;
    line-height: 1;
    flex-shrink: 0;
}
.chip-reject .tip-mark,
.mini-warn .tip-mark { background: #fecaca; color: #7f1d1d; }
.chip-branch .tip-mark { background: #bfdbfe; color: #1e3a8a; }

.tip-bubble {
    position: fixed;
    z-index: 200;
    max-width: min(320px, calc(100vw - 16px));
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
    pointer-events: none;
}
.tip-bubble[hidden] { display: none !important; }

.step-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 8px;
    margin-bottom: 4px;
}
.mini-tile {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 10px;
    background: var(--tile-code);
    border: 1px solid #dbe3ee;
}
.mini-pin { background: var(--tile-pin); border-color: #7dd3fc; }
.mini-person { background: var(--tile-person); border-color: #c4b5fd; }
.mini-time { background: var(--tile-time); border-color: #93c5fd; }
.mini-fee { background: var(--tile-fee); border-color: #6ee7b7; }
.mini-check { background: var(--tile-check); border-color: #5eead4; }
.mini-flag { background: var(--tile-flag); border-color: #e9d5ff; }
.mini-warn { background: var(--tile-warn); border-color: #fdba74; }
.mini-tile svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--brand);
}
.mini-fee svg { color: #047857; }
.mini-warn svg { color: #b45309; }
.mini-flag svg { color: #7c3aed; }
.mini-label {
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}
.mini-value {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 0;
    padding: 0;
    font-size: 0.84rem;
    font-weight: 650;
    color: #1e293b;
    text-align: start;
    cursor: help;
    line-height: 1.35;
}
.mini-value .tip-short {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.step-sla {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 1px 7px;
}

.left-workspace {
    background: #f4f8fd;
    border-color: #cfe0f5;
}
.stepper {
    list-style: none;
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 10px 4px 12px;
    scroll-snap-type: x proximity;
    background: #e8f1fb;
    border-radius: 12px;
}
.stepper li {
    position: relative;
    flex: 1 0 6.75rem;
    min-width: 6.75rem;
    scroll-snap-align: start;
    z-index: 1;
}
.stepper li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.35rem;
    left: calc(50% + 1.05rem);
    right: calc(-50% + 1.05rem);
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
}
.stepper li:has(.is-done):not(:last-child)::after {
    background: var(--brand);
}
.stepper-btn {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 5.1rem;
    border: 0;
    background: transparent;
    padding: 0 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    color: var(--ink);
    text-align: center;
}
.stepper-btn:hover .step-index {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px #dbeafe;
}
.stepper-btn:focus-visible {
    outline: none;
}
.stepper-btn:focus-visible .step-index {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}
.step-index {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 800;
    background: #fff;
    border: 3px solid #cbd5e1;
    color: #475569;
}
.step-label {
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.stepper-btn.is-done .step-index {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.stepper-btn.is-current .step-index {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
    box-shadow: 0 0 0 4px #fde68a;
}
.stepper-btn.is-current .step-label {
    color: #92400e;
}

@media (max-width: 700px) {
    .stepper {
        flex-direction: column;
        overflow: visible;
        gap: 0;
    }
    .stepper li {
        flex: none;
        min-width: 0;
        width: 100%;
    }
    .stepper li:not(:last-child)::after {
        top: 1.55rem;
        left: 1.18rem;
        width: 3px;
        height: calc(100% - 12px);
        right: auto;
    }
    .stepper-btn {
        flex-direction: row;
        justify-content: flex-start;
        min-height: 0;
        text-align: start;
        padding: 8px 8px 8px 0;
        gap: 12px;
    }
    .step-label {
        display: block;
        -webkit-line-clamp: unset;
        flex: 1;
    }
}

.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}
.btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s, opacity 0.15s;
}
.btn-secondary {
    border: 1px solid var(--line);
    color: #334155;
    background: #fff;
}
.btn-secondary:hover:not(:disabled) { background: var(--wash); }
.btn-primary {
    background: var(--brand);
    color: #fff;
    border: none;
}
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
#stepCounter {
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--muted);
    text-align: center;
}

.right-workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.right-workspace > .card-panel:first-child {
    background: #fff7ed;
    border-color: #fed7aa;
}
.milestone-meta-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
#milestoneTitle {
    font-weight: 700;
    font-size: 1.2rem;
    color: #1e293b;
}
.status-pill {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.status-pill.is-current {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: #bfdbfe;
}
.status-pill.is-done {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: #a7f3d0;
}
#milestoneDesc {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 14px;
}
#milestoneDesc.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: help;
}
.pro-tip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    background: var(--warn-soft);
    border: 1px solid #fde68a;
    color: var(--warn);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: help;
    align-self: flex-start;
}
.pro-tip svg {
    width: 16px;
    height: 16px;
}
.pro-tip[hidden] { display: none; }

.checklist-panel {
    flex: 1;
    background: #f7f5ff;
    border-color: #ddd6fe;
}
.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}
#txtDocMatrix {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
}
.checked-count {
    font-size: 0.75rem;
    color: #64748b;
}
#documentContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 320px;
}
.empty-docs {
    font-size: 0.9rem;
    color: #94a3b8;
    font-style: italic;
}
.doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #efeafc;
    border: 1px solid #ddd6fe;
    font-size: 0.9rem;
    color: #334155;
}
.doc-item:hover { background: #e4dbfa; }
.doc-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    cursor: pointer;
}
.doc-checkbox {
    height: 18px;
    width: 18px;
    cursor: pointer;
    flex-shrink: 0;
}
.doc-name { font-weight: 650; min-width: 0; }
.doc-main:has(.doc-checkbox:checked) .doc-name {
    color: #94a3b8;
    text-decoration: line-through;
}
.doc-tip {
    border: 0;
    background: transparent;
    padding: 2px;
    cursor: help;
    display: grid;
    place-items: center;
}
.doc-flag {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.doc-flag.is-required { color: var(--danger); }
.doc-flag.is-optional { color: #64748b; }

.print-btn { margin-top: 16px; align-self: flex-start; }

.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.fade-in-content { animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .fade-in-content { animation: none; }
    .btn, .stepper-btn { transition: none; }
}

.print-sheet[hidden] { display: none !important; }

@media print {
    .skip-link, header, .status-banner, .helper-brief, .left-workspace, .right-workspace, .tip-bubble {
        display: none !important;
    }
    .print-sheet[hidden] {
        display: block !important;
        padding: 12px;
        color: #000;
    }
    .print-sheet h1 { font-size: 1.4rem; margin-bottom: 8px; }
    .print-sheet h3 { margin: 16px 0 6px; font-size: 1.05rem; }
    .print-sheet ul { padding-left: 1.2rem; }
    .print-sheet li { margin: 4px 0; }
    .print-legend { margin-top: 24px; font-size: 0.85rem; }
    .print-meta { font-size: 0.85rem; color: #333; }
    .print-stamp { margin-top: 24px; border-top: 1px solid #000; padding-top: 12px; }
    .print-stamp p { margin: 8px 0; }
}

[dir="rtl"] .stepper-btn,
[dir="rtl"] .doc-item,
[dir="rtl"] .milestone-meta-header,
[dir="rtl"] .panel-header {
    text-align: start;
}
