:root {
    --teal-950: #064e4b;
    --teal-900: #075f5b;
    --teal-800: #08766f;
    --teal-700: #0a8f86;
    --teal-100: #dff5f1;
    --teal-50: #effaf8;
    --blue-600: #3182e8;
    --blue-50: #eef6ff;
    --orange-600: #e97727;
    --orange-50: #fff5eb;
    --red-600: #dc4c52;
    --red-50: #fff0f1;
    --green-600: #25865e;
    --green-50: #edf8f1;
    --ink: #17212f;
    --muted: #687386;
    --line: #e0e6eb;
    --wash: #f7f9fa;
    --paper: #ffffff;
    --radius: 10px;
    --shadow: 0 12px 36px rgba(18, 37, 54, 0.09);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif; background: var(--wash); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.toast { position: fixed; z-index: 200; right: 24px; top: 24px; max-width: 360px; padding: 13px 17px; border: 1px solid #bfe6de; border-radius: 9px; color: var(--teal-950); background: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(-12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #8a2830; border-color: #f1c5c8; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 0.85fr) minmax(520px, 1.15fr); background: white; }
.login-panel { width: min(520px, 100%); margin: auto; padding: 56px; }
.back-link { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 70px; color: var(--muted); text-decoration: none; font-size: .9rem; }
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 12px; font-weight: 900; }
.login-brand > span, .sidebar-brand > span { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: white; background: var(--teal-800); }
.login-kicker, .eyebrow { margin: 22px 0 8px; color: var(--teal-700); font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.login-panel h1 { margin: 0; max-width: 460px; font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.22; letter-spacing: -.035em; }
.login-copy { margin: 20px 0 34px; color: var(--muted); line-height: 1.8; }
.login-form { display: grid; gap: 18px; }
.login-form label span, .modal label span { display: block; margin-bottom: 7px; color: #4b5667; font-size: .85rem; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 44px; padding: 9px 12px; }
textarea { min-height: 92px; padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal-700); box-shadow: 0 0 0 3px rgba(10, 143, 134, .12); }
.service-notice { margin: 0 0 20px; padding: 12px 14px; border: 1px solid #f1d09d; border-radius: 8px; color: #7e5017; background: #fff9ed; font-size: .88rem; line-height: 1.6; }
.login-visual { display: grid; place-items: center; min-height: 100vh; padding: 56px; background: var(--teal-50); }
.visual-sheet { width: min(540px, 92%); padding: 40px; border: 1px solid #cae8e3; border-radius: 18px; background: white; box-shadow: 0 28px 80px rgba(7, 95, 91, .12); }
.visual-sheet p { margin: 0; color: var(--muted); font-weight: 800; }
.visual-sheet > strong { display: block; margin: 8px 0 34px; color: var(--teal-900); font-size: 4rem; }
.visual-sheet small { font-size: 1rem; }
.visual-line { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 16px; margin-top: 22px; color: #4d5b68; }
.visual-line b { height: 8px; border-radius: 10px; background: #e7efef; overflow: hidden; }
.visual-line b::before { content: ""; display: block; width: var(--progress); height: 100%; background: var(--teal-700); }

.primary-button, .soft-button, .outline-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 15px; border-radius: 8px; font-weight: 800; }
.primary-button { border: 1px solid var(--teal-700); color: white; background: var(--teal-700); }
.primary-button:hover { background: var(--teal-800); }
.soft-button { border: 1px solid #cfe5e1; color: var(--teal-900); background: var(--teal-50); }
.outline-button { width: 100%; border: 1px solid var(--line); color: var(--teal-900); background: white; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; color: #d7efec; background: var(--teal-950); }
.sidebar-brand { padding: 0 10px 26px; color: white; font-size: 1.08rem; }
.sidebar-brand > span { background: white; color: var(--teal-900); }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav button, .sidebar-footer a { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 10px 14px; border: 0; border-radius: 8px; color: #d7efec; background: transparent; text-decoration: none; text-align: left; }
.sidebar-nav button i, .sidebar-footer a i { width: 20px; text-align: center; }
.sidebar-nav button.active, .sidebar-nav button:hover, .sidebar-footer a:hover { color: white; background: rgba(255,255,255,.12); }
.sidebar-footer { display: grid; gap: 4px; margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding-top: 12px; }
.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 40; min-height: 72px; display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; align-items: center; gap: 24px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.topbar.global-view .account-area { grid-column: 3; }
.event-selector-wrap { display: flex; gap: 8px; align-items: center; }
#eventSelector { width: min(260px, 38vw); font-weight: 800; }
.event-meta { min-width: 0; color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-area { position: relative; display: flex; align-items: center; gap: 8px; }
.icon-button { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; color: #435161; background: white; }
.notice-dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border: 2px solid white; border-radius: 50%; background: var(--teal-700); }
.account-button { display: flex; align-items: center; gap: 9px; padding: 4px 6px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.account-button strong, .account-button small { display: block; }
.account-button small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--teal-900); background: var(--teal-100); }
.account-menu { position: absolute; top: 50px; right: 0; width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: var(--shadow); }
.account-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 6px; background: white; color: #394656; text-align: left; }
.account-menu button:hover { background: var(--wash); }
.mobile-menu { display: none; }

.workspace { width: min(1500px, 100%); margin: 0 auto; padding: 28px 30px 42px; }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.workspace-header .eyebrow { margin: 0 0 7px; }
.workspace-header h1 { margin: 0; font-size: 1.65rem; letter-spacing: -.02em; }
.workspace-header p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.phase-tabs { display: flex; gap: 38px; border-bottom: 1px solid var(--line); background: white; padding: 0 18px; }
.phase-tabs button { min-width: 64px; padding: 16px 4px 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #536173; font-weight: 800; }
.phase-tabs button.active { color: var(--teal-900); border-color: var(--teal-700); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 18px; margin-top: 18px; }
.task-panel, .summary-card, .secondary-workspace, .overview-grid > section { border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.filter-row { display: flex; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chips button { min-height: 34px; padding: 6px 10px; border: 1px solid transparent; border-radius: 7px; color: #606c7c; background: #f4f6f7; font-size: .82rem; }
.filter-chips button.active { color: var(--teal-900); border-color: #bfe2dc; background: var(--teal-50); }
.search-box { min-width: 230px; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; color: #87919d; background: white; }
.search-box input { min-height: 34px; padding: 0; border: 0; box-shadow: none; }
.table-wrap { overflow-x: auto; }
.task-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.task-table th { height: 48px; padding: 10px 12px; color: #4f5a69; background: #fafbfb; font-size: .8rem; text-align: left; }
.task-table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; font-size: .86rem; }
.task-table tr { transition: background .15s ease; }
.task-table tbody tr:hover { background: #fbfdfd; }
.task-table td:nth-child(2) { min-width: 235px; }
.task-title-button { padding: 0; border: 0; color: var(--ink); background: transparent; text-align: left; }
.task-title-button strong { display: block; margin-bottom: 5px; }
.task-title-button small { color: var(--muted); }
.check-col { width: 42px; }
.task-check { width: 18px; height: 18px; accent-color: var(--teal-700); }
.tag, .status-pill, .priority-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 6px; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.tag { color: var(--teal-900); background: var(--teal-50); }
.priority-high { color: var(--orange-600); background: var(--orange-50); }
.priority-medium { color: #9a7416; background: #fff9e7; }
.priority-low { color: #687386; background: #f1f4f5; }
.status-todo { color: #687386; background: #f1f4f5; }
.status-doing { color: var(--blue-600); background: var(--blue-50); }
.status-done { color: var(--green-600); background: var(--green-50); }
.overdue-date { color: var(--red-600); font-weight: 800; }
.table-footer { display: flex; justify-content: space-between; padding: 12px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.table-empty { padding: 56px; color: var(--muted); text-align: center; }
.summary-column { display: grid; align-content: start; gap: 18px; }
.summary-card { padding: 18px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-heading h2 { margin: 0; font-size: 1rem; }
.card-heading button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: .76rem; }
.progress-card > strong { display: block; margin-top: 30px; color: var(--teal-800); font-size: 2.6rem; }
.progress-card > p { margin: 4px 0 20px; color: var(--muted); }
.progress-track { height: 8px; border-radius: 10px; background: #edf0f2; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--teal-700); transition: width .3s ease; }
.progress-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; color: var(--muted); font-size: .72rem; }
.progress-breakdown b { display: block; margin-top: 5px; color: var(--ink); font-size: .9rem; }
.empty-state { min-height: 420px; display: grid; place-items: center; align-content: center; padding: 40px; border: 1px dashed #b8cfcb; border-radius: 12px; background: white; text-align: center; }
.empty-state > i { color: var(--teal-700); font-size: 2.8rem; }
.empty-state h2 { margin: 20px 0 6px; }
.empty-state p { max-width: 540px; margin: 0 0 22px; color: var(--muted); line-height: 1.7; }

.secondary-workspace { margin-top: 18px; padding: 20px; }
.material-section-tabs { display: flex; gap: 28px; margin: -4px 0 20px; border-bottom: 1px solid var(--line); }
.material-section-tabs button { padding: 12px 4px 11px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 800; }
.material-section-tabs button.active { color: var(--teal-900); border-color: var(--teal-700); }
.metric-grid, .overview-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
#materialMetrics { grid-template-columns: repeat(4, 1fr); }
.metric-card { padding: 18px; border: 1px solid var(--line); border-radius: 8px; }
.metric-card span { color: var(--muted); font-size: .82rem; }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.65rem; }
.materials-toolbar { display: flex; justify-content: space-between; gap: 14px; margin: 18px 0; }
.materials-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.materials-scope { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.material-list { display: grid; gap: 8px; }
.material-row { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(470px, 2fr) minmax(250px, .8fr); gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.material-name strong, .material-name small { display: block; }
.material-name small { margin-top: 5px; color: var(--muted); font-size: .74rem; }
.material-name small b { color: var(--teal-800); letter-spacing: .04em; }
.material-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.material-row button { border: 0; background: transparent; color: var(--teal-800); text-align: right; }
.material-row button.danger-link { color: var(--red-600); }
.material-quantities, .inventory-inline-summary { display: grid; grid-template-columns: repeat(4, minmax(72px, 1fr)); gap: 7px; }
.inventory-inline-summary { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--wash); }
.quantity-cell { min-width: 0; padding: 8px 9px; border-radius: 7px; background: #f3f6f6; }
.quantity-cell small, .quantity-cell strong { display: block; }
.quantity-cell small { color: var(--muted); font-size: .67rem; }
.quantity-cell strong { margin-top: 4px; font-size: .88rem; }
.quantity-cell em { color: var(--muted); font-size: .67rem; font-style: normal; font-weight: 500; }
.quantity-available { color: var(--green-600); background: var(--green-50); }
.quantity-outbound, .quantity-pending { color: var(--blue-600); background: var(--blue-50); }
.quantity-damaged { color: var(--red-600); background: var(--red-50); }
.quantity-needed { color: #93651e; background: #fff8e8; }
.field-label { display: block; margin-bottom: 7px; color: #4b5667; font-size: .85rem; font-weight: 800; }
.inventory-action-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.inventory-action-options button { min-height: 68px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; text-align: left; }
.inventory-action-options button strong, .inventory-action-options button small { display: block; }
.inventory-action-options button small { margin-top: 5px; color: var(--muted); }
.inventory-action-options button.active { border-color: var(--teal-700); color: var(--teal-900); background: var(--teal-50); box-shadow: 0 0 0 2px rgba(10,143,134,.1); }
.input-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .74rem; }
.material-action-summary { display: grid; grid-template-columns: 1fr auto; gap: 7px 16px; padding: 16px; border: 1px solid #cae5e0; border-radius: 9px; background: var(--teal-50); }
.material-action-summary span { color: var(--teal-800); font-weight: 900; letter-spacing: .06em; }
.material-action-summary small { grid-column: 1 / -1; color: var(--muted); }
.material-label-preview { display: grid; justify-items: center; gap: 10px; min-height: 270px; padding: 26px; border: 1px dashed #b8cfcb; border-radius: 10px; background: white; }
.material-label-preview img { max-width: min(420px, 100%); max-height: 190px; object-fit: contain; }
.material-label-preview strong { color: var(--teal-900); letter-spacing: .1em; }
.material-label-preview small { color: var(--muted); }
.inventory-history { display: grid; gap: 8px; max-height: 430px; overflow-y: auto; }
.inventory-history article { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 8px; }
.history-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--teal-800); background: var(--teal-50); }
.inventory-history strong, .inventory-history p, .inventory-history small { display: block; margin: 0; }
.inventory-history p, .inventory-history small { margin-top: 4px; color: var(--muted); font-size: .75rem; }
.inventory-history article > span:last-child { color: var(--muted); font-size: .76rem; }
.scanner-box { position: relative; min-height: 260px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; color: var(--muted); background: #102322; text-align: center; }
.scanner-box video { width: 100%; max-height: 360px; object-fit: cover; }
#scannerPlaceholder { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; padding: 30px; background: var(--teal-50); }
#scannerPlaceholder i { color: var(--teal-700); font-size: 3rem; }
#scannerPlaceholder p { max-width: 330px; line-height: 1.7; }
.labels-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.labels-heading h2 { margin: 0; font-size: 1.05rem; }
.labels-heading p { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.label-list { display: grid; gap: 8px; }
.label-row { display: grid; grid-template-columns: 24px 42px minmax(200px, 1fr) minmax(130px, auto) minmax(190px, auto); align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; }
.label-check { width: 18px; height: 18px; accent-color: var(--teal-700); }
.label-code-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; color: var(--teal-800); background: var(--teal-50); }
.label-row strong, .label-row small { display: block; }
.label-row strong { color: var(--teal-900); letter-spacing: .05em; }
.label-row small { margin-top: 4px; color: var(--muted); font-size: .74rem; }
.label-actions { display: flex; justify-content: flex-end; gap: 12px; }
.label-actions button { border: 0; color: var(--teal-800); background: transparent; }
.print-label-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.print-label-grid article { min-height: 220px; display: grid; justify-items: center; align-content: center; gap: 8px; padding: 18px; border: 1px dashed #b8cfcb; border-radius: 9px; break-inside: avoid; }
.print-label-grid img { max-width: 100%; max-height: 140px; object-fit: contain; }
.print-label-grid small { color: var(--muted); }
.ledger-list { display: grid; gap: 8px; }
.ledger-row { display: grid; grid-template-columns: 40px minmax(220px, 1fr) minmax(130px, auto) minmax(150px, auto); align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; }
.ledger-main strong, .ledger-main small, .ledger-main p { display: block; margin: 0; }
.ledger-main small, .ledger-main p { margin-top: 4px; color: var(--muted); font-size: .74rem; }
.ledger-row > b { color: var(--teal-900); font-size: .82rem; text-align: right; }
.transaction-actions { display: flex; justify-content: flex-end; gap: 10px; }
.transaction-actions button { border: 0; color: var(--teal-800); background: transparent; }
.transaction-actions button.danger-link { color: var(--red-600); }
@media print {
    body * { visibility: hidden; }
    .modal, .modal * { visibility: visible; }
    .modal { position: fixed; inset: 0; width: 100%; max-width: none; border: 0; box-shadow: none; }
    .modal > header, .modal-actions { display: none !important; }
    .print-label-grid { grid-template-columns: repeat(2, 1fr); }
}
.events-workspace { margin-top: 18px; }
.events-list-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 14px; }
.events-list-heading h2 { margin: 0; font-size: 1.05rem; }
.events-list-heading p { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.events-list-heading > span { color: var(--muted); font-size: .82rem; font-weight: 800; }
.event-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.event-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: white; transition: border-color .18s ease, box-shadow .18s ease; }
.event-card:hover, .event-card.current { border-color: #b8dcd6; box-shadow: 0 10px 28px rgba(7, 95, 91, .07); }
.event-card > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.event-card > header > div { display: flex; gap: 7px; }
.event-card > header small { color: var(--teal-800); font-weight: 800; }
.event-status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 6px; font-size: .76rem; font-weight: 800; }
.event-card h3 { margin: 17px 0 13px; font-size: 1.05rem; }
.event-card > p { margin: 8px 0; color: var(--muted); font-size: .8rem; }
.event-card > p i { width: 18px; color: var(--teal-700); text-align: center; }
.event-progress { margin-top: 18px; padding: 13px; border-radius: 8px; background: var(--wash); }
.event-progress > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: .76rem; }
.event-progress > div:first-child strong { color: var(--teal-900); }
.event-progress > div:nth-child(2) { height: 7px; margin: 9px 0 7px; overflow: hidden; border-radius: 8px; background: #e5eaec; }
.event-progress > div:nth-child(2) span { display: block; height: 100%; background: var(--teal-700); }
.event-progress small { color: var(--muted); font-size: .7rem; }
.event-card > footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.event-card-actions { display: flex; align-items: center; gap: 4px; }
.event-card-actions > button { min-height: 36px; padding: 7px 8px; border: 0; color: var(--teal-800); background: transparent; font-weight: 800; }
.event-delete-button { min-height: 38px; padding: 8px 10px; border: 0; color: var(--red-600); background: transparent; font-weight: 800; }
.event-card-actions > .event-delete-button { color: var(--red-600); }
.event-list-empty { grid-column: 1 / -1; min-height: 300px; display: grid; place-items: center; align-content: center; padding: 40px; border: 1px dashed #b8cfcb; border-radius: var(--radius); background: white; text-align: center; }
.event-list-empty > i { color: var(--teal-700); font-size: 2.4rem; }
.event-list-empty h3 { margin: 16px 0 6px; }
.event-list-empty p { margin: 0; color: var(--muted); }
.phase-score-panel { margin-top: 18px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.section-heading h2 { margin: 0; font-size: 1rem; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.phase-progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.phase-score-card { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfc; }
.phase-score-card > header { padding: 16px; border-bottom: 1px solid var(--line); background: white; }
.phase-score-card > header > div:first-child { display: flex; justify-content: space-between; align-items: center; }
.phase-score-label { color: var(--teal-900); font-weight: 900; }
.phase-score-card > header strong { color: var(--teal-800); font-size: 1.45rem; }
.phase-score-card > header small { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; }
.phase-score-track { height: 8px; margin-top: 12px; overflow: hidden; border-radius: 8px; background: #e8edef; }
.phase-score-track span { display: block; height: 100%; background: var(--teal-700); }
.department-score-list { display: grid; gap: 1px; background: var(--line); }
.department-score-row { display: grid; grid-template-columns: minmax(80px, 1fr) 1.4fr 34px 42px; gap: 8px; align-items: center; padding: 11px 12px; background: white; font-size: .75rem; }
.department-score-row > span { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.department-score-row > div { height: 6px; overflow: hidden; border-radius: 8px; background: #e8edef; }
.department-score-row > div span { display: block; height: 100%; background: var(--teal-700); }
.department-score-row small { color: var(--muted); text-align: right; }
.department-score-row b { color: var(--teal-900); text-align: right; }

.people-workspace { margin-top: 18px; }
.people-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.people-grid > section { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.people-grid > section > header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 17px; border-bottom: 1px solid var(--line); }
.people-grid h2 { margin: 0; font-size: 1rem; }
.people-grid header p { margin: 5px 0 0; color: var(--muted); font-size: .75rem; }
.people-list { display: grid; }
.person-row { display: grid; grid-template-columns: 38px minmax(120px, 1fr) auto auto; gap: 11px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.person-row:last-child { border-bottom: 0; }
.person-row.inactive { opacity: .56; }
.person-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--teal-800); background: var(--teal-50); }
.person-row strong, .person-row small { display: block; }
.person-row small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.role-badge { padding: 5px 7px; border-radius: 6px; color: var(--teal-900); background: var(--teal-50); font-size: .7rem; font-weight: 800; }
.person-actions { display: flex; justify-content: flex-end; gap: 6px; }
.person-actions button { padding: 6px 7px; border: 0; color: var(--teal-800); background: transparent; font-size: .72rem; font-weight: 800; }
.person-actions button.danger-link { color: var(--red-600); }

.template-workspace { padding: 0; overflow: hidden; }
.template-toolbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; padding: 22px; border-bottom: 1px solid var(--line); }
.template-toolbar .eyebrow { margin: 0 0 6px; }
.template-toolbar h2 { margin: 0; font-size: 1.1rem; }
.template-toolbar p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: .84rem; }
.template-toolbar label { width: min(250px, 100%); }
.template-toolbar label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: .75rem; font-weight: 800; }
.template-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); background: #fbfcfc; }
.template-summary > div { padding: 16px 22px; border-right: 1px solid var(--line); }
.template-summary > div:last-child { border-right: 0; }
.template-summary span, .template-summary strong { display: block; }
.template-summary span { color: var(--muted); font-size: .74rem; }
.template-summary strong { margin-top: 6px; font-size: 1.08rem; }
.template-task-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 18px; background: var(--wash); }
.template-phase-column { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: white; }
.template-phase-column > header { padding: 13px 14px; border-bottom: 1px solid var(--line); background: #fafbfb; }
.template-phase-column > header div { display: flex; justify-content: space-between; align-items: center; }
.template-phase-column > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.template-phase-column > header > button { padding: 6px 8px; border: 1px solid #cfe5e1; border-radius: 6px; color: var(--teal-900); background: var(--teal-50); font-size: .7rem; font-weight: 800; }
.template-phase-column > header span { font-weight: 900; }
.template-phase-column > header strong { color: var(--muted); font-size: .76rem; }
.template-phase-list { display: grid; gap: 9px; padding: 10px; }
.template-department-group { overflow: hidden; border: 1px solid #dbe5e6; border-radius: 8px; background: #fbfdfd; }
.template-department-group > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #dbe5e6; background: var(--teal-50); }
.template-department-group > header > div { display: flex; align-items: center; gap: 8px; }
.template-department-group > header strong { font-size: .83rem; }
.template-department-actions { display: flex; align-items: center; gap: 3px; }
.template-department-group > header small { margin-right: 3px; color: var(--muted); font-size: .7rem; }
.template-department-actions button { width: 27px; height: 27px; border: 0; border-radius: 6px; color: var(--teal-800); background: white; }
.template-department-actions button.danger-link { color: var(--red-600); }
.template-department-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--teal-800); background: white; }
.template-department-group > div { display: grid; gap: 8px; padding: 8px; }
.template-task-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.template-task-heading { display: flex; justify-content: space-between; gap: 8px; }
.template-task-heading > span:first-child { color: var(--muted); font-size: .72rem; }
.template-task-card h3 { margin: 12px 0 6px; font-size: .9rem; line-height: 1.45; }
.template-task-card p { min-height: 38px; margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.6; }
.template-task-card footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.template-task-card footer div { display: flex; gap: 4px; }
.template-task-card footer button { width: 30px; height: 30px; border: 0; border-radius: 6px; color: var(--teal-800); background: var(--teal-50); }
.template-task-card footer button.danger-link { color: var(--red-600); background: var(--red-50); }
.template-empty { padding: 32px 12px; color: var(--muted); text-align: center; font-size: .8rem; }
.template-empty.compact { padding: 18px 10px; }
.add-department-task { width: 100%; min-height: 35px; border: 1px dashed #b7d7d2; border-radius: 7px; color: var(--teal-800); background: white; font-size: .74rem; font-weight: 800; }
.form-hint { margin: -4px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.6; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(13, 28, 35, .48); }
.modal { width: min(650px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 13px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.2); }
.modal > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); background: white; }
.modal header .eyebrow { margin: 0 0 4px; }
.modal h2 { margin: 0; }
.modal form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; padding: 22px; }
.modal .wide { grid-column: 1 / -1; }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }

@media (max-width: 1120px) {
    .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
    .sidebar-brand strong, .sidebar-nav span, .sidebar-footer span { display: none; }
    .sidebar-brand { justify-content: center; padding-inline: 0; }
    .sidebar-nav button, .sidebar-footer a { justify-content: center; }
    .content-grid { grid-template-columns: 1fr; }
    .summary-column { grid-template-columns: 1fr; }
    .event-meta { display: none; }
    .event-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .template-task-board, .phase-progress, .people-grid { grid-template-columns: 1fr; }
    #materialMetrics { grid-template-columns: repeat(3, 1fr); }
    .material-row { grid-template-columns: 1fr; }
    .material-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-panel { padding: 30px 24px; }
    .login-visual { display: none; }
    .back-link { margin-bottom: 44px; }
    .app-shell { display: block; }
    .sidebar { position: fixed; left: -240px; z-index: 80; width: 220px; transition: left .2s ease; }
    .sidebar.open { left: 0; }
    .sidebar-brand strong, .sidebar-nav span, .sidebar-footer span { display: block; }
    .sidebar-nav button, .sidebar-footer a { justify-content: flex-start; }
    .topbar { grid-template-columns: auto 1fr auto; padding: 10px 12px; }
    .mobile-menu { display: inline-grid; }
    .event-selector-wrap .soft-button, .account-button > span:not(.avatar), .account-button > i { display: none; }
    #eventSelector { width: 100%; }
    .workspace { padding: 20px 12px 32px; }
    .workspace-header { align-items: stretch; flex-direction: column; }
    .phase-tabs { gap: 12px; overflow-x: auto; }
    .filter-row, .materials-toolbar { flex-direction: column; }
    .materials-toolbar-actions { align-items: stretch; justify-content: space-between; }
    .search-box { width: 100%; min-width: 0; }
    .summary-column, .metric-grid, .overview-metrics, .template-summary { grid-template-columns: 1fr; }
    #materialMetrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .template-toolbar { align-items: stretch; flex-direction: column; }
    .events-list-heading { align-items: flex-start; flex-direction: column; }
    .event-list { grid-template-columns: 1fr; }
    .template-toolbar label { width: 100%; }
    .template-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
    .template-summary > div:last-child { border-bottom: 0; }
    .person-row { grid-template-columns: 38px 1fr; }
    .role-badge, .person-actions { grid-column: 2; justify-content: flex-start; }
    .material-row { grid-template-columns: 1fr; }
    .material-quantities, .inventory-inline-summary { grid-template-columns: repeat(2, 1fr); }
    .material-actions { justify-content: flex-start; }
    .labels-heading { align-items: stretch; flex-direction: column; }
    .label-row { grid-template-columns: 24px 42px 1fr; }
    .label-row > .tag, .label-actions { grid-column: 3; justify-content: flex-start; }
    .print-label-grid { grid-template-columns: 1fr; }
    .inventory-action-options { grid-template-columns: 1fr; }
    .ledger-row { grid-template-columns: 40px 1fr; }
    .ledger-row > b, .transaction-actions { grid-column: 2; justify-content: flex-start; text-align: left; }
    .inventory-history article { grid-template-columns: 38px 1fr; }
    .inventory-history article > span:last-child { grid-column: 2; }
    .modal form { grid-template-columns: 1fr; }
    .modal .wide { grid-column: auto; }
    .modal-actions { grid-column: auto; }
}
