* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px;
    color: #172033;
    background: #f1f5f9;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2 {
    margin: 0 0 12px;
}

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

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

input, select, textarea {
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid #c5d0df;
    border-radius: 4px;
    background: #fff;
    color: #172033;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    outline: 0;
}

textarea {
    resize: vertical;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

th, td {
    border: 0;
    border-bottom: 1px solid #dbe3ee;
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #334155;
    background: #eef3f8;
    font-weight: 700;
}

tbody tr:hover {
    background: #f8fbff;
}

tbody tr {
    transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

tbody tr:not(.ok):not(.warn):not(.idle):not(.bad):hover td:first-child {
    box-shadow: inset 5px 0 0 #2563eb;
}

tr.ok:hover td:first-child { box-shadow: inset 5px 0 0 #16a34a; }
tr.warn:hover td:first-child { box-shadow: inset 5px 0 0 #f59e0b; }
tr.idle:hover td:first-child { box-shadow: inset 5px 0 0 #94a3b8; }
tr.bad:hover td:first-child { box-shadow: inset 5px 0 0 #dc2626; }

td.actions {
    text-align: left;
}

.install-daily-table td.fixed-tone-empty { background: #f8fafc; }
.install-daily-table td.fixed-tone-mid { background: #fff8e8; }
.install-daily-table td.fixed-tone-high { background: #f0fdf4; }
.install-daily-table td.fixed-tone-done { background: #eaf8ef; }

.install-daily-table .progress-cell {
    color: #0f172a;
    font-weight: 700;
}

.install-daily-table .date-tone-0 { background: #f2f7ff; }
.install-daily-table .date-tone-1 { background: #f3fbf6; }
.install-daily-table .date-tone-2 { background: #fff8ee; }
.install-daily-table .date-tone-3 { background: #fff4fa; }
.install-daily-table .date-tone-4 { background: #f7f5ff; }
.install-daily-table .date-tone-5 { background: #effcfd; }

.install-daily-table th.date-group {
    text-align: center;
}

.install-daily-table th {
    text-align: center;
}

.install-daily-table .col-uninstalled {
    background: #fff8ee;
    text-align: center;
}

.install-daily-table .col-uninstalled-remark {
    min-width: 120px;
}

.install-daily-table .col-seq {
    position: sticky;
    left: 0;
    z-index: 6;
    min-width: 58px;
    background: #fff;
}

.install-daily-table .col-county {
    position: sticky;
    left: 58px;
    z-index: 6;
    min-width: 104px;
    background: #fff;
}

.install-daily-table .col-dept {
    position: sticky;
    left: 162px;
    z-index: 6;
    min-width: 190px;
    background: #fff;
    box-shadow: 1px 0 0 #dbe3ee;
}

.install-daily-table thead .col-seq,
.install-daily-table thead .col-county,
.install-daily-table thead .col-dept {
    z-index: 8;
    background: #eef3f8;
}

.install-daily-table tbody .col-seq.fixed-tone-empty,
.install-daily-table tbody .col-county.fixed-tone-empty,
.install-daily-table tbody .col-dept.fixed-tone-empty {
    background: #f8fafc;
}

.install-daily-table tbody .col-seq.fixed-tone-mid,
.install-daily-table tbody .col-county.fixed-tone-mid,
.install-daily-table tbody .col-dept.fixed-tone-mid {
    background: #fff8e8;
}

.install-daily-table tbody .col-seq.fixed-tone-high,
.install-daily-table tbody .col-county.fixed-tone-high,
.install-daily-table tbody .col-dept.fixed-tone-high {
    background: #f0fdf4;
}

.install-daily-table tbody .col-seq.fixed-tone-done,
.install-daily-table tbody .col-county.fixed-tone-done,
.install-daily-table tbody .col-dept.fixed-tone-done {
    background: #eaf8ef;
}

.install-daily-table tbody .col-dept {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uninstalled-remark-cell {
    min-width: 120px;
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
    text-align: left;
}

.installer-remark-details summary {
    cursor: pointer;
    color: #2563eb;
    white-space: nowrap;
}

details {
    transition: background 160ms ease, border-color 160ms ease;
}

details[open] {
    animation: detailsReveal 180ms ease both;
}

.installer-remark-lines {
    display: grid;
    gap: 6px;
    max-height: 120px;
    overflow: auto;
    margin-top: 6px;
}

.installer-remark-lines div + div {
    margin-top: 0;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.remark-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    line-height: 1.45;
}

.remark-line span {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.remark-date {
    color: #1e3a8a;
    background: #dbeafe;
}

.remark-count {
    color: #166534;
    background: #dcfce7;
}

.remark-category {
    color: #7c2d12;
    background: #ffedd5;
    border: 1px solid #fed7aa;
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.remark-reporter {
    color: #475569;
    background: #e2e8f0;
}

.remark-line strong {
    flex: 1 1 100%;
    min-width: 120px;
    color: #172033;
    font-weight: 600;
    word-break: break-word;
}

.dept-stock-info {
    display: grid;
    gap: 8px;
    border-color: #d5deea;
    color: #334155;
    background: #f8fafc;
}

.dept-stock-info div {
    display: grid;
    grid-template-columns: 70px repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
}

.dept-stock-info strong {
    color: #0f172a;
    font-size: 13px;
}

.dept-stock-info span {
    color: #475569;
    font-size: 13px;
}

.dept-stock-info p {
    margin: 0;
    color: #8a5a16;
}

.sortable-table th[data-sortable="true"] {
    cursor: pointer;
    user-select: none;
}

.sortable-table th[data-sortable="true"] .sort-label {
    display: inline;
}

.sortable-table th[data-sortable="true"] .sort-label::after {
    content: "↕";
    margin-left: 6px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1;
}

.sortable-table th[aria-sort="ascending"] .sort-label::after {
    content: "↑";
    color: #2563eb;
}

.sortable-table th[aria-sort="descending"] .sort-label::after {
    content: "↓";
    color: #2563eb;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.topnav .inline-form {
    margin: 0;
}

.topnav .inline-form .btn {
    width: 100%;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid #d5deea;
    border-radius: 4px;
    color: #334155;
    background: #f8fafc;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.nav-link:hover {
    border-color: #93b4ee;
    color: #1d4ed8;
    background: #eef5ff;
}

.nav-link.active {
    border-color: #2563eb;
    color: #fff;
    background: #2563eb;
}

.nav-user {
    color: #475569;
    white-space: nowrap;
}

section {
    margin-bottom: 18px;
}

.section-subhead {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 8px 0 10px;
}

.section-subhead h3 {
    margin: 0;
    color: #0f172a;
    font-size: 16px;
}

.section-subhead + .table-wrap {
    margin-bottom: 16px;
}

.toolbar, .filter-box {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 16px;
}

.export-menu {
    position: relative;
}

.export-menu summary {
    list-style: none;
}

.export-menu summary::-webkit-details-marker {
    display: none;
}

.export-menu div {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 0;
    display: grid;
    min-width: 220px;
    padding: 8px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.export-menu a {
    padding: 9px 10px;
    border-radius: 6px;
    color: #334155;
}

.export-menu a:hover {
    color: #1d4ed8;
    background: #eef5ff;
}

.filter-box {
    gap: 10px 12px;
    padding: 14px;
    background: #fff;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.filter-box input[type="text"] {
    width: min(300px, 100%);
}

.filter-box span {
    color: #64748b;
    font-size: 13px;
}

.filter-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px 0 16px;
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    color: #334155;
    background: #f8fbff;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.05);
}

.filter-summary span {
    color: #1d4ed8;
    font-weight: 700;
}

.filter-summary b {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    color: #172033;
    background: #fff;
    font-size: 12px;
}

.quick-filters,
.column-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px 0 16px;
}

.quick-filters span,
.column-panel summary {
    color: #475569;
    font-weight: 700;
}

.quick-filters a,
.column-panel label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 9px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    color: #334155;
    background: #fff;
}

.quick-filters a.active,
.quick-filters a:hover {
    border-color: #93b4ee;
    color: #1d4ed8;
    background: #eef5ff;
}

.column-panel {
    padding: 10px 0 2px;
}

.column-panel summary {
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    transition: filter 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.btn.primary { background: #2563eb; }
.btn.success { background: #15803d; }
.btn.secondary {
    border: 1px solid #cbd5e1;
    color: #334155;
    background: #fff;
}
.btn.danger { background: #dc2626; }
.btn.edit { background: #f97316; }
.btn.payload-btn {
    border: 1px solid #cbd5e1;
    color: #334155;
    background: #fff;
}
.btn.payload-btn:hover {
    border-color: #93b4ee;
    color: #1d4ed8;
    background: #eef5ff;
}
.btn:hover {
    filter: brightness(0.96);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}
.btn:active {
    transform: translateY(1px);
}
.btn:focus-visible,
.nav-link:focus-visible,
.dialog-close:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}
.btn.disabled,
.btn:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    filter: none;
}
.btn.small {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
}
.btn.full {
    width: 100%;
}

.auth-card, .form-card {
    width: 520px;
    max-width: 100%;
    margin: 70px auto;
    padding: 24px;
    background: #fff;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.auth-card {
    width: 340px;
}

.login-card label {
    font-weight: 700;
}

.wide-form {
    width: 760px;
}

.upload-card {
    width: min(1180px, 100%);
    margin-top: 28px;
}

.auth-card form, .form-card form {
    display: grid;
    gap: 12px;
}

.form-card label {
    font-weight: 700;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px 12px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
}

.check-grid label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}


.messages {
    margin: 0 0 12px;
}

.message {
    padding: 10px 12px;
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #86efac;
    border-radius: 6px;
}

.muted {
    color: #64748b;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
    scrollbar-color: #cbd5e1 #f8fafc;
}

.table-wrap table {
    min-width: max-content;
}

.table-wrap::-webkit-scrollbar {
    height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
    background: #f8fafc;
}

.table-wrap::-webkit-scrollbar-thumb {
    border: 2px solid #f8fafc;
    border-radius: 999px;
    background: #cbd5e1;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cell-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.inline-form input,
.inline-form select {
    min-height: 30px;
}

.user-actions {
    min-width: 560px;
}

#installReportForm select,
#installReportForm textarea,
#installReportForm input {
    width: 100%;
}

#installReportForm textarea {
    line-height: 1.55;
}

.mobile-report-list {
    display: none;
}

.wrap-cell {
    min-width: 180px;
    max-width: 360px;
    white-space: normal;
    word-break: break-word;
}

.summary-note-cell {
    min-width: 240px;
    max-width: 340px;
}

.dept-note-details {
    margin-bottom: 6px;
}

.dept-note-details summary {
    max-width: 320px;
    cursor: pointer;
    color: #334155;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dept-note-form {
    display: grid;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 6px;
}

.dept-note-form textarea {
    width: 100%;
    min-height: 48px;
    resize: vertical;
}

.daily-remark-summary {
    display: grid;
    gap: 3px;
    max-height: 86px;
    overflow: auto;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    line-height: 1.45;
    color: #334155;
}

.info-line {
    padding: 9px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    color: #1e3a8a;
    background: #eff6ff;
}

.info-warn {
    border-color: #fcd34d;
    color: #92400e;
    background: #fffbeb;
}

.info-ok {
    border-color: #86efac;
    color: #166534;
    background: #f0fdf4;
}

.import-preview {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.import-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.confirm-import-form {
    padding: 12px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #f8fafc;
}

.import-preview-table td:nth-child(2) {
    min-width: 220px;
    max-width: 380px;
    white-space: normal;
}

.import-error-text {
    margin-top: 5px;
    color: #7f1d1d;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
}

tr.ok { background: #f2fbf5; }
tr.warn { background: #fffbeb; }
tr.idle { background: #f8fafc; }
tr.bad { background: #fff1f2; }

tr.ok td:first-child { box-shadow: inset 4px 0 0 #16a34a; }
tr.warn td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
tr.idle td:first-child { box-shadow: inset 4px 0 0 #94a3b8; }
tr.bad td:first-child { box-shadow: inset 4px 0 0 #dc2626; }

.status-badge {
    display: inline-block;
    min-width: 64px;
    max-width: 100%;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.status-ok {
    border-color: #bbf7d0;
    color: #166534;
    background: #f0fdf4;
}

.status-warn {
    border-color: #fde68a;
    color: #92400e;
    background: #fffbeb;
}

.status-idle {
    border-color: #dbe3ee;
    color: #475569;
    background: #f8fafc;
}

.status-bad {
    border-color: #fecdd3;
    color: #b91c1c;
    background: #fff1f2;
}

.mini-progress {
    display: inline-flex;
    width: 76px;
    height: 8px;
    overflow: hidden;
    margin-right: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    vertical-align: middle;
}

.mini-progress i {
    display: block;
    width: var(--rate);
    min-width: 3px;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    transform-origin: left center;
    animation: progressGrow 720ms ease-out both;
}

.heat-cell {
    position: relative;
    font-weight: 700;
    text-align: center;
}

.heat-zero {
    color: #94a3b8;
}

.heat-low {
    color: #166534;
    background: #dcfce7 !important;
}

.heat-mid {
    color: #14532d;
    background: #86efac !important;
}

.heat-high {
    color: #052e16;
    background: #22c55e !important;
}

.power-timeline {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 320px;
}

.power-timeline span {
    position: relative;
    display: grid;
    gap: 3px;
    min-width: 92px;
    padding-left: 14px;
}

.power-timeline span::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 4px;
    width: calc(100% + 8px);
    height: 2px;
    background: #cbd5e1;
}

.power-timeline span:last-child::before {
    display: none;
}

.power-timeline i {
    position: absolute;
    z-index: 1;
    top: 1px;
    left: 0;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 0 0 2px #bfdbfe;
}

.power-timeline b {
    color: #1d4ed8;
    font-size: 12px;
}

.power-timeline em {
    color: #475569;
    font-style: normal;
    font-size: 12px;
}

.detail-drawer {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    width: min(420px, calc(100vw - 24px));
    height: 100vh;
    border-left: 1px solid #dbe3ee;
    background: #fff;
    box-shadow: -24px 0 70px rgba(15, 23, 42, 0.22);
    transform: translateX(105%);
    transition: transform 220ms ease;
}

.detail-drawer.open {
    transform: translateX(0);
}

.detail-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(15, 23, 42, 0.28);
    opacity: 0;
    transition: opacity 180ms ease;
}

.detail-drawer-backdrop.open {
    opacity: 1;
}

.detail-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #dbe3ee;
    background: #f8fafc;
}

.detail-drawer-body {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    overflow: auto;
}

.detail-drawer-body div {
    display: grid;
    gap: 3px;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.detail-drawer-body span {
    color: #64748b;
    font-size: 12px;
}

.detail-drawer-body strong {
    color: #172033;
    font-weight: 700;
    word-break: break-word;
}

td.muted[colspan] {
    padding: 24px;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    background: #f8fafc;
    text-align: center;
}

.asset-ledger-table th:nth-child(1),
.asset-ledger-table td:nth-child(1),
.unknown-ledger-table th:nth-child(1),
.unknown-ledger-table td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 146px;
    background: inherit;
}

.asset-ledger-table th:nth-child(2),
.asset-ledger-table td:nth-child(2) {
    position: sticky;
    left: 146px;
    z-index: 3;
    min-width: 96px;
    background: inherit;
}

.asset-ledger-table th:nth-child(3),
.asset-ledger-table td:nth-child(3) {
    position: sticky;
    left: 242px;
    z-index: 3;
    min-width: 150px;
    background: inherit;
    box-shadow: 1px 0 0 #dbe3ee;
}

.unknown-ledger-table th:nth-child(2),
.unknown-ledger-table td:nth-child(2) {
    position: sticky;
    left: 146px;
    z-index: 3;
    min-width: 130px;
    background: inherit;
    box-shadow: 1px 0 0 #dbe3ee;
}

.asset-ledger-table th:last-child,
.asset-ledger-table td:last-child,
.unknown-ledger-table th:last-child,
.unknown-ledger-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 3;
    min-width: 112px;
    background: inherit;
    box-shadow: -1px 0 0 #dbe3ee;
}

.asset-ledger-table th:nth-child(-n+3),
.unknown-ledger-table th:nth-child(-n+2),
.asset-ledger-table th:last-child,
.unknown-ledger-table th:last-child {
    z-index: 4;
    background: #eef3f8;
}

.asset-ledger-table td:nth-child(4),
.asset-ledger-table td:nth-child(6),
.asset-ledger-table td:nth-child(7),
.unknown-ledger-table td:nth-child(2),
.unknown-ledger-table td:nth-child(3) {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.pager a, .pager span {
    padding: 6px 12px;
    border: 1px solid #2563eb;
    border-radius: 4px;
    background: #fff;
}

.pager a {
    color: #1d4ed8;
}

.pager .disabled {
    color: #94a3b8;
    border-color: #cbd5e1;
}

.pager-size-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.pager-size-form label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
}

.pager-size-form select {
    min-height: 32px;
    padding: 4px 26px 4px 8px;
}

.density-compact {
    font-size: 13px;
}

.density-compact th,
.density-compact td {
    padding: 5px 8px;
}

.density-compact input,
.density-compact select,
.density-compact textarea,
.density-compact .btn,
.density-compact .nav-link {
    min-height: 30px;
}

.density-compact .btn {
    padding: 6px 10px;
}

.density-compact .btn.small {
    min-height: 24px;
    padding: 3px 7px;
}

.density-compact .filter-box {
    padding: 10px;
}

.density-compact .metric {
    min-height: 104px;
    padding: 12px;
}

.density-compact .metric strong {
    margin: 6px 0 4px;
    font-size: 26px;
}

.density-compact .panel {
    padding: 12px;
}

.density-compact .status-badge {
    min-height: 20px;
    padding: 2px 7px;
    font-size: 11px;
}

.payload-dialog {
    position: fixed;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 32px));
    margin: 0;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.payload-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.payload-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #cbd5e1;
    background: #f8fafc;
}

.dialog-close {
    width: 30px;
    height: 30px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #334155;
    cursor: pointer;
}

#payloadContent {
    max-height: 560px;
    margin: 0;
    padding: 14px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    color: #172033;
    font: 13px/1.5 Consolas, "Courier New", monospace;
}

.report-dialog {
    width: min(1100px, calc(100vw - 32px));
}

.report-dialog-content {
    max-height: 620px;
    padding: 14px;
    overflow: auto;
}

.dashboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.dashboard-head h2 {
    margin-bottom: 6px;
    font-size: 24px;
}

.dashboard-head p {
    margin: 0;
}

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

.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 12px;
}

.metric {
    min-height: 128px;
    padding: 16px;
    border: 1px solid #dbe3ee;
    border-top: 4px solid #64748b;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.045);
    animation: liftIn 420ms ease both;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.metric:hover {
    border-color: #bfd0e6;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.metric span,
.metric em {
    display: block;
    color: #64748b;
    font-style: normal;
}

.metric strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 32px;
    line-height: 1;
    letter-spacing: 0;
}

.metric-detail-list {
    display: grid;
    gap: 3px;
    max-height: 58px;
    overflow: auto;
    padding-right: 2px;
    color: #334155;
    font-size: 12px;
    line-height: 1.35;
}

.metric-detail-list div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-main { border-top-color: #2563eb; }
.metric-ok { border-top-color: #16a34a; }
.metric-warn { border-top-color: #f97316; }
.metric-idle { border-top-color: #64748b; }
.metric-bad { border-top-color: #dc2626; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 14px;
}

.panel {
    padding: 16px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.045);
    animation: liftIn 480ms ease both;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.panel:hover {
    border-color: #cbd8ea;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.065);
}

.panel-map {
    min-height: 560px;
}

.panel-wide {
    grid-column: span 1;
}

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

.panel-head h2 {
    margin: 0;
    font-size: 18px;
}

.panel-head a {
    color: #2563eb;
}

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

.install-panel {
    min-height: 100%;
}

.panel-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 16px;
}

.panel-stat-grid div {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.panel-stat-grid span {
    display: block;
    color: #64748b;
    font-size: 12px;
}

.panel-stat-grid strong {
    display: block;
    margin-top: 6px;
    color: #0f172a;
    font-size: 22px;
    line-height: 1.1;
}

.panel-stat-grid em {
    display: block;
    margin-top: 5px;
    color: #64748b;
    font-style: normal;
    font-size: 12px;
    line-height: 1.35;
}

.county-list,
.recent-list {
    display: grid;
    gap: 10px;
}

.county-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 2fr) 58px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1f2937;
    background: #f8fafc;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.county-row:hover,
.mini-donut-card:hover {
    border-color: #bfd0e6;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.county-meta strong,
.county-meta span {
    display: block;
}

.county-meta span {
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}

.progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #16a34a;
}

.county-row b {
    text-align: right;
}

.compare-row {
    grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 2fr) 56px auto;
}

.compare-row .btn {
    justify-self: end;
}

.county-detail-toggle.active {
    background: #2563eb;
}

.county-dept-dropdown {
    display: none;
    gap: 8px;
    margin: -4px 0 4px;
    padding: 10px 12px 10px 28px;
    border: 1px solid #dbe4ef;
    border-top: 0;
    border-radius: 0 0 6px 6px;
    background: #fff;
}

.county-dept-dropdown.open {
    display: grid;
}

.dept-progress-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.2fr) minmax(120px, 2fr) 54px;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid #edf2f7;
    border-radius: 6px;
    background: #f8fafc;
}

.dept-progress-row .progress {
    height: 8px;
}

.dept-progress-row b {
    text-align: right;
    color: #334155;
    font-size: 12px;
}

.recent-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid #e2e8f0;
    color: #1f2937;
    transition: background 140ms ease;
}

.recent-item:hover {
    background: #f8fafc;
}

.recent-item:last-child {
    border-bottom: 0;
}

.recent-item strong,
.recent-item span,
.recent-item em {
    display: block;
    min-width: 0;
}

.recent-item strong {
    overflow-wrap: anywhere;
}

.recent-item span,
.recent-item em {
    margin-top: 3px;
    color: #64748b;
    font-style: normal;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.status-dot {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 50%;
}

.dot-ok { background: #16a34a; }
.dot-bad { background: #dc2626; }

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: center;
    gap: 14px;
}

.city-map {
    position: relative;
    min-height: 500px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.city-map svg {
    display: block;
    width: 100%;
    height: auto;
}

.map-region path {
    stroke: #fff;
    stroke-width: 1.2;
    cursor: pointer;
    transition: fill 180ms ease, transform 180ms ease, filter 180ms ease;
}

.map-region:hover path {
    filter: brightness(0.94);
    transform: translateY(-1px);
}

.map-region text {
    pointer-events: none;
    fill: #0f172a;
    font-size: 13px;
    font-weight: 700;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 3px;
}

.map-high path { fill: #16a34a; }
.map-mid path { fill: #f59e0b; }
.map-low path { fill: #ef4444; }
.map-empty path { fill: #cbd5e1; }

.map-marker {
    cursor: pointer;
}

.map-marker .marker-pulse {
    fill: currentColor;
    opacity: 0.18;
    animation: markerPulse 1.8s ease-out infinite;
}

.map-marker .marker-dot {
    fill: currentColor;
    stroke: #fff;
    stroke-width: 2;
}

.map-marker text {
    fill: #0f172a;
    font-size: 13px;
    font-weight: 700;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.95);
    stroke-width: 3px;
}

.map-marker.map-high { color: #16a34a; }
.map-marker.map-mid { color: #f59e0b; }
.map-marker.map-low { color: #ef4444; }
.map-marker.map-empty { color: #64748b; }

.map-tooltip {
    position: absolute;
    z-index: 5;
    min-width: 170px;
    padding: 10px 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.map-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.chart-tooltip {
    position: fixed;
}

.map-tooltip strong,
.map-tooltip span {
    display: block;
}

.map-tooltip strong {
    margin-bottom: 6px;
    font-size: 15px;
}

.map-tooltip span {
    margin-top: 3px;
    color: #cbd5e1;
    font-size: 12px;
}

.map-legend,
.chart-legend {
    display: grid;
    gap: 10px;
}

.map-legend span,
.chart-legend a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
}

.map-legend i,
.chart-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-high,
.legend-ok { background: #16a34a; }
.legend-mid,
.legend-warn { background: #f59e0b; }
.legend-low,
.legend-bad { background: #ef4444; }
.legend-empty,
.legend-idle { background: #94a3b8; }
.legend-marker {
    border-radius: 50%;
    background: #334155;
}

.donut-wrap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 230px;
}

.donut {
    position: relative;
    display: grid;
    place-items: center;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: conic-gradient(
        #16a34a 0 var(--done),
        #f59e0b var(--done) var(--failed),
        #94a3b8 var(--failed) var(--offline),
        #ef4444 var(--offline) 100%
    );
    animation: spinIn 720ms ease-out both;
}

.donut::after {
    content: "";
    position: absolute;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: #fff;
}

.donut-center {
    position: absolute;
    text-align: center;
}

.donut-center strong,
.donut-center span {
    display: block;
}

.donut-center strong {
    font-size: 30px;
    line-height: 1;
}

.donut-center span {
    margin-top: 5px;
    color: #64748b;
}

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

.mini-donut-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 9px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1f2937;
    background: #f8fafc;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.mini-donut-card strong,
.mini-donut-card span {
    display: block;
}

.mini-donut-card strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-donut-card span {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
}

.mini-donut {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: conic-gradient(
        #16a34a 0 var(--done),
        #f59e0b var(--done) var(--failed),
        #94a3b8 var(--failed) var(--offline),
        #e2e8f0 var(--offline) 100%
    );
}

.mini-donut::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: #f8fafc;
}

@keyframes liftIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spinIn {
    from {
        opacity: 0;
        transform: rotate(-80deg) scale(0.92);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes markerPulse {
    from {
        opacity: 0.32;
        transform: scale(0.7);
    }
    to {
        opacity: 0;
        transform: scale(1.8);
    }
}

@keyframes progressGrow {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

@keyframes detailsReveal {
    from {
        opacity: 0.72;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 1180px) {
    .summary-grid {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .install-compare-grid {
        grid-template-columns: 1fr;
    }

    .map-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    html {
        background: #eef2f7;
    }

    body {
        min-height: 100vh;
        padding: max(10px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
        font-size: 16px;
    }

    h2 {
        font-size: 20px;
        line-height: 1.25;
    }

    .topbar,
    .dashboard-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        gap: 12px;
        padding: 12px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .topnav {
        width: 100%;
    }

    .nav-user {
        order: -1;
        width: 100%;
        font-size: 13px;
    }

    .topnav .nav-link,
    .topnav .btn {
        flex: 1 1 calc(50% - 4px);
        min-height: 42px;
        padding: 9px 10px;
    }

    .topnav .inline-form {
        flex: 1 1 calc(50% - 4px);
    }

    .auth-card,
    .form-card,
    .wide-form {
        width: 100%;
        margin: 14px 0;
        padding: 16px;
    }

    .login-card {
        margin-top: clamp(44px, 12vh, 92px);
        padding: 22px 18px;
        border-radius: 8px;
        box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    }

    .login-card h2 {
        margin-bottom: 18px;
        text-align: center;
    }

    .login-card form {
        gap: 10px;
    }

    .install-card {
        margin-top: 8px;
    }

    .dashboard-head {
        gap: 2px;
        margin-bottom: 10px;
        padding: 0 2px;
    }

    .dashboard-head p {
        margin: 0;
        line-height: 1.45;
    }

    #installReportForm {
        gap: 10px;
    }

    #installReportForm label {
        margin-top: 2px;
    }

    input,
    select,
    textarea,
    .btn {
        min-height: 46px;
        font-size: 16px;
    }

    input,
    select,
    textarea {
        padding: 10px 12px;
    }

    .toolbar,
    .filter-box,
    .dashboard-actions {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .toolbar .btn,
    .filter-box .btn,
    .filter-box input,
    .filter-box select,
    .filter-box a {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
        position: sticky;
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 3;
        margin: 6px -2px 0;
        padding-top: 6px;
        background: linear-gradient(rgba(255,255,255,0), #fff 35%);
    }

    .form-actions .btn {
        width: 100%;
        min-height: 48px;
        font-weight: 700;
    }

    .check-grid {
        grid-template-columns: 1fr;
    }

    .info-line {
        padding: 10px 12px;
        line-height: 1.45;
    }

    .table-wrap {
        margin: 0 -10px;
        padding: 0 10px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        -webkit-overflow-scrolling: touch;
    }

    th,
    td {
        padding: 8px;
    }

    .wrap-cell {
        min-width: 220px;
        max-width: 280px;
    }

    .install-card + section .table-wrap {
        display: none;
    }

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

    .mobile-report-card {
        padding: 12px;
        border: 1px solid #d7dee8;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
    }

    .mobile-report-card.warn-card {
        border-color: #fbbf24;
        background: #fffbeb;
    }

    .mobile-report-head {
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }

    .mobile-report-head strong {
        min-width: 0;
        font-size: 16px;
        line-height: 1.35;
        word-break: break-word;
    }

    .mobile-report-head span,
    .mobile-report-card em {
        flex: 0 0 auto;
        color: #64748b;
        font-style: normal;
        font-size: 12px;
    }

    .mobile-report-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 8px;
    }

    .mobile-report-meta span,
    .tag-warn {
        padding: 3px 7px;
        border-radius: 4px;
        color: #475569;
        background: #f1f5f9;
        font-size: 12px;
    }

    .tag-warn {
        color: #92400e;
        background: #fef3c7;
    }

    .mobile-count-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 10px;
    }

    .mobile-count-grid div {
        padding: 10px;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        background: #f8fafc;
    }

    .mobile-count-grid span,
    .mobile-count-grid strong {
        display: block;
    }

    .mobile-count-grid span {
        color: #64748b;
        font-size: 12px;
    }

    .mobile-count-grid strong {
        margin-top: 3px;
        font-size: 22px;
    }

    .mobile-report-card p {
        margin: 10px 0 0;
        line-height: 1.5;
        word-break: break-word;
    }

    .mobile-report-card p b {
        display: block;
        margin-bottom: 3px;
        color: #334155;
    }

    .mobile-report-card em {
        display: block;
    }

    .mobile-report-foot {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 10px;
    }

    .mobile-report-foot form {
        margin: 0;
    }

    .mobile-empty {
        padding: 14px;
        border: 1px dashed #cbd5e1;
        border-radius: 8px;
        background: #fff;
        text-align: center;
    }

    .user-actions {
        min-width: 360px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .metric {
        min-height: auto;
    }

    .metric strong {
        font-size: 28px;
    }

    .panel-stat-grid {
        grid-template-columns: 1fr;
    }

    .county-row {
        grid-template-columns: 1fr;
    }

    .compare-row .btn {
        justify-self: start;
    }

    .dept-progress-row {
        grid-template-columns: 1fr;
    }

    .dept-progress-row b {
        text-align: left;
    }

    .county-row b {
        text-align: left;
    }

    .mini-donut-grid {
        grid-template-columns: 1fr;
    }

    .dept-stock-info div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
