:root {
    --page-bg: #ffffff;
    --card-bg: #F2F2F7;
    --text: #1D1D1F;
    --muted: #86868B;
    --line: #D2D2D7;
    --line-strong: #C7C7CC;
    --blue: #007AFF;
    --red: #FF3B30;
    --orange: #FF9500;
    --yellow: #FFCC00;
    --green: #34C759;
    --gray: #8E8E93;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--page-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
}

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

button,
input,
select,
textarea {
    border-radius: 8px;
}

.site-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 16px 40px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.brand-mark {
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.landing-page .site-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    padding-top: 12px;
}

.landing-title {
    margin: 8px 0 0;
    font-size: clamp(2rem, 6vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.03em;
}

.landing-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}

.landing-grid {
    width: min(100%, 760px);
    display: grid;
    gap: 16px;
}

.persona-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    padding: 32px 28px;
    text-decoration: none;
    transition: border-color 0.15s ease, padding 0.15s ease;
}

.persona-card:hover,
.persona-card:focus-visible {
    border: 2px solid var(--blue);
    border-radius: 12px;
    padding: 31px 27px;
    outline: none;
}

.persona-icon {
    font-size: 2rem;
    line-height: 1;
}

.persona-name {
    margin-top: 18px;
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.persona-region {
    margin-top: 10px;
    color: var(--muted);
    font-size: 1rem;
}

.persona-count {
    margin-top: 6px;
    color: var(--blue);
    font-size: 0.875rem;
    font-weight: 600;
}

.landing-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
}

.dashboard-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.dashboard-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--blue);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
}

.back-link:hover,
.back-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.dashboard-title-wrap {
    flex: 1 1 240px;
}

.dashboard-title {
    margin: 6px 0 0;
    font-size: clamp(1.9rem, 5vw, 2.8rem);
    font-weight: 600;
    letter-spacing: -0.03em;
}

.dashboard-meta {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.header-print,
.secondary-btn,
.assign-btn,
.notes-toggle,
.modal-cancel,
.modal-confirm {
    min-height: 44px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    padding: 10px 14px;
    cursor: pointer;
}

.header-print,
.assign-btn,
.modal-confirm {
    border-color: var(--blue);
}

.header-print,
.assign-btn {
    color: var(--blue);
}

.modal-confirm {
    background: var(--blue);
    color: #ffffff;
}

.triage-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.triage-filter {
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    background: #ffffff;
    color: var(--text);
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.triage-filter.active {
    border-color: var(--blue);
    border-radius: 20px;
    background: var(--blue);
    color: #ffffff;
}

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.search-field {
    flex: 1 1 280px;
}

#searchInput,
.assign-select,
.status-select,
.notes-input {
    width: 100%;
    min-height: 44px;
    border: 1px solid #c6ccd2;
    background: #ffffff;
    padding: 10px 12px;
}

.progress {
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
}

.wo-list {
    display: grid;
    gap: 12px;
}

.wo-card {
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 12px;
    background: var(--card-bg);
    padding: 16px;
}

.wo-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.wo-number {
    font-size: 15px;
    font-weight: 700;
}

.wo-number-link {
    color: var(--blue);
    text-decoration: none;
}

.wo-number-link:hover,
.wo-number-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.wo-chip-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.urgency-chip,
.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    border-radius: 999px;
}

.urgency-critical {
    background: var(--red);
    color: #ffffff;
}

.urgency-urgent {
    background: var(--orange);
    color: #ffffff;
}

.urgency-high {
    background: var(--yellow);
    color: #1D1D1F;
}

.urgency-medium {
    background: var(--blue);
    color: #ffffff;
}

.urgency-low {
    background: var(--gray);
    color: #ffffff;
}

.status-chip.complete {
    border: 1px solid #b6dec4;
    background: #e6f4ea;
    color: #126c3d;
}

.status-chip.waiting {
    border: 1px solid #ffe08a;
    background: #fff3cd;
    color: #7a5a00;
}

.status-chip.scheduled {
    border: 1px solid #c6dbff;
    background: #e7f1ff;
    color: #0a58ca;
}

.status-chip.cancel {
    border: 1px solid #ced4da;
    background: #e9ecef;
    color: #495057;
}

.wo-main {
    font-size: 14px;
    line-height: 1.5;
}

.wo-main > div + div {
    margin-top: 4px;
}

.wo-description {
    margin: 4px 0;
}

.wo-actions {
    margin-top: 16px;
    display: grid;
    gap: 12px;
}

.wo-action-group {
    display: grid;
    gap: 8px;
}

.wo-action-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.wo-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.assign-select {
    flex: 1 1 220px;
}

.assign-btn {
    flex: 0 0 auto;
}

.status-select {
    min-width: 0;
}

.notes-toggle {
    justify-self: start;
}

.notes-wrap {
    margin-top: 12px;
}

.notes-input {
    min-height: 88px;
    resize: vertical;
}

.note-print,
.print-only {
    display: none;
}

.wo-card.status-complete {
    border-left-color: var(--green) !important;
    background: #f4fbf6;
}

.wo-card.status-complete .wo-main {
    color: #5f6a63;
    text-decoration: line-through;
}

.wo-card.status-waiting {
    border-left-color: var(--yellow) !important;
}

.wo-card.status-scheduled {
    border-left-color: var(--blue) !important;
}

.wo-card.status-cancel {
    border-left-color: var(--gray) !important;
    background: #f1f3f5;
}

.wo-card.status-cancel .wo-main {
    color: #6c757d;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(51, 51, 51, 0.55);
    z-index: 1000;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(100%, 420px);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    padding: 24px;
}

.modal-title {
    margin: 0 0 12px;
    font-size: 1.2rem;
}

.modal-message {
    margin: 0 0 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.modal-open {
    overflow: hidden;
}

@media (min-width: 720px) {
    .landing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wo-actions {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
        align-items: end;
    }
}

@media (max-width: 719px) {
    .dashboard-header-top {
        align-items: stretch;
    }

    .header-print,
    .secondary-btn {
        width: 100%;
    }

    .wo-head {
        flex-direction: column;
    }

    .wo-chip-group {
        justify-content: flex-start;
    }
}

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

    .site-shell {
        max-width: none;
        padding: 0;
    }

    .no-print,
    .modal-backdrop {
        display: none !important;
    }

    .triage-bar,
    .controls {
        display: none !important;
    }

    .dashboard-header {
        border-bottom-color: #999999;
    }

    .wo-list {
        display: block;
    }

    .wo-card {
        margin-bottom: 8px;
        background: #ffffff;
        border-radius: 0;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .wo-card.status-complete .wo-main {
        color: #444444;
    }

    .wo-number-link {
        color: #000000;
        text-decoration: none;
    }

    .print-only {
        display: block !important;
    }
}
