:root {
  --page: #f4f7f8;
  --panel: #fff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e1e8;
  --nav: #233142;
  --nav2: #314358;
  --teal: #0f766e;
  --blue: #2563a9;
  --amber: #a86612;
  --rose: #ad3f59;
  --shadow: 0 14px 34px rgba(31, 41, 51, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.app { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { background: var(--nav); color: #edf3f6; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.brand-row { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 42px; height: 42px; border-radius: 8px; background: #e5b54f; color: #1f2933; display: grid; place-items: center; font-weight: 900; }
.brand-row h1 { margin: 0; font-size: 17px; }
.brand-row p { margin: 5px 0 0; color: #b9c7d4; font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav-btn, .logout, .sidebar-refresh { min-height: 42px; border-radius: 8px; padding: 0 12px; color: #d7e2ea; background: transparent; display: flex; align-items: center; text-decoration: none; font-weight: 700; }
.nav-btn.active, .nav-btn:hover, .logout:hover, .sidebar-refresh:hover { background: var(--nav2); color: #fff; }
.sidebar-refresh { width: 100%; border: 1px solid rgba(255,255,255,.16); justify-content: flex-start; }
.logout { margin-top: auto; border: 1px solid rgba(255,255,255,.16); }

.main { min-width: 0; padding: 12px; display: grid; gap: 12px; align-content: start; }
.primary, .ghost { min-height: 40px; border-radius: 8px; padding: 0 14px; font-weight: 800; }
.primary { background: var(--teal); color: #fff; }
.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }

.kpis { display: grid; gap: 8px; }
.kpis article {
  min-height: 60px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
}
.kpis span { color: #b9c7d4; font-size: 12px; }
.kpis strong { display: block; margin-top: 5px; color: #fff; font-size: 18px; line-height: 1.1; overflow-wrap: anywhere; }
.panel, .table-card, .detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 17px; }
.panel-head span, #rowCount { color: var(--muted); font-size: 13px; }
.filters { display: grid; grid-template-columns: minmax(320px, 520px); gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px 10px; color: var(--ink); }
textarea { min-height: 80px; resize: vertical; }
.multi-filter { position: relative; min-width: 0; }
.multi-filter-btn { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; font-weight: 700; }
.multi-filter-btn .filter-btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-filter-btn .filter-caret { color: var(--muted); }
.multi-filter-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; min-width: 260px; }
.multi-filter.open .multi-filter-menu { display: block; }
.multi-option-list { max-height: 260px; overflow: auto; display: grid; gap: 3px; }
.multi-option { min-height: 34px; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--ink); font-size: 13px; line-height: 1.25; }
.multi-option:hover { background: #f0f7f6; }
.multi-option input { width: 16px; min-height: 16px; flex: 0 0 auto; }
.filter-search { min-height: 34px; margin: 0 0 8px; }
.multi-option.hidden-by-search { display: none; }
.all-option { border-bottom: 1px solid var(--line); margin-bottom: 6px; font-weight: 800; }
.tree-filter-menu { min-width: 390px; }
.filter-tree { max-height: 430px; overflow: auto; display: grid; gap: 6px; }
.filter-group { border: 1px solid #e7edf2; border-radius: 8px; overflow: hidden; }
.filter-group-row { background: #f8fafb; font-weight: 900; }
.filter-group-row small { color: var(--muted); font-weight: 800; }
.tree-expand { width: 24px; min-height: 24px; padding: 0; border-radius: 6px; background: #eef3f7; color: var(--muted); font-weight: 900; flex: 0 0 auto; }
.tree-expand:hover { color: var(--teal); background: #e2f1ef; }
.filter-child-list { display: grid; gap: 2px; padding: 4px 0 6px; }
.filter-group:not(.expanded) .filter-child-list { display: none; }
.filter-child { padding-left: 30px; }
.filter-ungrouped { border-top: 1px solid var(--line); padding-top: 6px; display: grid; gap: 3px; }
.bulk-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.bulk-toolbar strong { margin-right: 6px; white-space: nowrap; }
.bulk-toolbar select { width: auto; min-width: 190px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; align-items: start; }
.table-card { overflow: auto; height: calc(100vh - 210px); min-height: 560px; }
.table-card.is-empty { height: calc(100vh - 210px); min-height: 560px; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; font-size: 13px; }
th, td { text-align: left; vertical-align: top; border-bottom: 1px solid #e7edf2; padding: 10px; }
th { position: sticky; top: 0; background: #f8fafb; color: #344054; z-index: 1; }
th:has(.table-filter.open) { z-index: 30; }
.hidden-col { display: none; }
.sortable-th { white-space: nowrap; }
.th-tools { display: inline-flex; align-items: center; gap: 5px; position: relative; }
.sort-btn { min-height: 28px; padding: 0; background: transparent; color: #344054; font-weight: 900; display: inline-flex; align-items: center; gap: 5px; }
.sort-btn:hover, .sort-btn.active { color: var(--teal); }
.icon-sort-btn { width: 28px; min-width: 28px; justify-content: center; border-radius: 6px; background: #eef3f7; }
.icon-sort-btn:hover, .icon-sort-btn.active { background: #e2f1ef; }
.clock-icon { font-size: 15px; line-height: 1; }
.status-th-tools { gap: 4px; }
.account-status-th-tools { display: inline-grid; gap: 5px; align-items: start; justify-items: start; }
.account-status-header-row { display: inline-flex; align-items: center; gap: 5px; position: relative; }
.sort-arrow { font-size: 12px; line-height: 1; }
.sort-clear { width: 22px; min-height: 22px; margin-left: 4px; border-radius: 999px; background: #eef3f7; color: var(--muted); font-weight: 900; line-height: 1; }
.sort-clear:hover { background: #ffe5eb; color: var(--rose); }
.table-filter { position: static; }
.table-filter .multi-filter-btn { width: auto; min-width: 34px; min-height: 28px; max-width: 112px; padding: 0 7px; border-radius: 6px; font-size: 12px; overflow: hidden; }
.table-filter .multi-filter-menu { top: calc(100% + 8px); left: 0; right: auto; text-align: left; white-space: normal; }
.table-filter .tree-filter-menu { min-width: 420px; }
.account-col .table-filter .multi-filter-menu, .amount-col .table-filter .multi-filter-menu, .source-status-col .table-filter .multi-filter-menu, .account-status-col .table-filter .multi-filter-menu { left: auto; right: 0; }
tr { cursor: default; }
tr:hover td, tr.selected td { background: #f0f7f6; }
.empty-row td { height: 420px; }
.check-col { width: 72px; min-width: 72px; text-align: center; }
.check-col input { width: 16px; min-height: 16px; padding: 0; cursor: pointer; }
.check-col:hover { cursor: crosshair; }
.row-actions { display: flex; align-items: center; justify-content: center; gap: 7px; }
.row-open { width: 24px; min-height: 24px; padding: 0; border-radius: 6px; background: #eef3f7; color: var(--muted); font-weight: 900; line-height: 1; }
.row-open:hover { background: #e2f1ef; color: var(--teal); }
.drag-selecting-rows, .drag-selecting-rows * { user-select: none; }
.amount-col { text-align: right; }
.amount-col .sort-btn { justify-content: flex-end; width: 100%; }
.address-stack { display: grid; gap: 4px; min-width: 300px; }
.address { font-weight: 800; overflow-wrap: anywhere; }
.address-region, .address-request-id, .address-service { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.pvz-inline { color: var(--muted); font-weight: 800; white-space: nowrap; }
.muted { color: var(--muted); }
.badge { display: inline-flex; min-height: 26px; align-items: center; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 800; white-space: nowrap; background: #e5effb; color: var(--blue); }
.status-stack { display: inline-grid; gap: 4px; justify-items: start; align-content: start; }
.account-status-stack { display: inline-grid; gap: 4px; justify-items: start; align-content: start; }
.account-status-account, .work-status-text { color: var(--text); font-size: 13px; font-weight: 800; line-height: 1.25; }
.source-status-text { color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.25; }
.status-date { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.25; white-space: nowrap; }
.badge.paid { background: #d9f0ed; color: var(--teal); }
.badge.work { background: #fff1d6; color: var(--amber); }
.badge.risk { background: #ffe5eb; color: var(--rose); }
.badge.unknown-work-status { background: #ffe5eb; color: var(--rose); outline: 1px solid rgba(196, 36, 72, 0.18); }
.detail-card { min-height: 400px; overflow: hidden; }
.detail-head { padding: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.detail-head h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.detail-body { padding: 14px; display: grid; gap: 12px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.info { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fbfcfd; }
.info span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.info strong { overflow-wrap: anywhere; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.small-btn { min-height: 34px; border-radius: 8px; padding: 0 10px; border: 1px solid var(--line); background: #fff; font-weight: 800; }
.small-btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.small-btn.danger { background: var(--rose); color: #fff; border-color: var(--rose); }
.detail-full { margin: 14px; box-shadow: none; }
.stream { display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.stream-item { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); font-size: 13px; }
.stream-item strong { color: var(--ink); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos img, .photos video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-report-panel { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.photo-report-toggle { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; font-weight: 900; cursor: pointer; }
.photo-report-toggle:hover { border-color: var(--teal); color: var(--teal); }
.photo-report-toggle b { color: var(--muted); font-size: 12px; }
.photo-report-toggle[aria-expanded="false"] b { color: var(--teal); }
.photo-report-content { display: grid; gap: 8px; }
.photo-report-content.collapsed { display: none; }
.photo-report-form { display: grid; gap: 8px; }
.photo-report-form textarea { min-height: 64px; }
.report-subtype { display: grid; grid-template-columns: minmax(180px, 260px) minmax(220px, 360px); gap: 8px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 800; }
.report-subtype select { min-height: 34px; }
.photo-section { display: grid; gap: 6px; }
.photo-section h4 { margin: 0; font-size: 16px; }
.photo-slot-grid { display: grid; grid-template-columns: repeat(3, minmax(200px, 1fr)); gap: 7px; }
.photo-slot { display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 8px; }
.photo-slot.paste-active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.photo-slot strong { font-size: 13px; line-height: 1.25; }
.photo-slot strong span { color: var(--rose); }
.slot-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.slot-file-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot-file-btn { min-height: 30px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 5px 10px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.slot-file-btn:hover { border-color: var(--teal); color: var(--teal); }
.slot-counter { color: var(--muted); font-weight: 900; white-space: nowrap; }
.slot-counter.missing { color: var(--rose); }
.slot-counter.complete { color: var(--teal); }
.slot-paste-zone { min-height: 28px; border-radius: 7px; border: 1px dashed #9ab7b2; background: #f5fbfa; color: var(--teal); font-weight: 800; padding: 4px 8px; text-align: left; }
.slot-paste-zone:focus, .slot-paste-zone:hover { background: #e2f1ef; outline: none; }
.photo-slot small { color: var(--muted); font-size: 12px; line-height: 1.25; }
.slot-previews { display: flex; flex-wrap: wrap; gap: 6px; }
.media-preview-wrap { position: relative; display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 3px 8px; width: 100%; min-width: 0; color: var(--muted); font-size: 10px; align-items: start; }
.media-preview { display: grid; gap: 3px; width: 68px; color: var(--muted); text-decoration: none; font-size: 10px; }
.media-preview img, .media-preview video { width: 68px; aspect-ratio: 1; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); background: #fff; }
.media-delete { position: absolute; top: -7px; left: 57px; width: 22px; min-height: 22px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--rose); font-weight: 900; line-height: 1; padding: 0; cursor: pointer; box-shadow: 0 4px 12px rgba(17, 24, 39, .14); }
.media-delete:hover { border-color: var(--rose); background: #fff2f5; }
.pasted-preview img { border-color: var(--teal); }
.media-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-status { grid-column: 2; align-self: center; font-size: 11px; line-height: 1.25; font-style: normal; white-space: normal; overflow-wrap: anywhere; }
.media-status.success { color: #087f5b; font-weight: 800; }
.media-status.pending { color: var(--muted); }
.media-status.error { color: var(--rose); font-weight: 800; }
.drive-link { color: var(--teal); font-weight: 900; }
.import-form { padding: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.import-form input { max-width: 460px; }
.inner-head { border-top: 1px solid var(--line); margin-top: 6px; }
.manual-import-form { padding: 14px; display: grid; gap: 10px; }
.manual-import-form textarea { width: 100%; min-height: 150px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; line-height: 1.45; }
button:disabled { opacity: .55; cursor: wait; }
.notice { padding: 0 14px 14px; color: var(--muted); }
.roles { padding: 14px; display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 12px; }
.roles article { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.roles h4 { margin: 0 0 8px; }
.roles p { margin: 0; color: var(--muted); line-height: 1.45; }
.drive-settings { padding: 14px; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr); gap: 12px; }
.drive-settings article { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #fbfcfd; display: grid; gap: 10px; align-content: start; }
.drive-settings h4 { margin: 0; }
.drive-settings p { margin: 0; color: var(--muted); line-height: 1.45; }
.drive-settings code { display: block; padding: 8px; border-radius: 7px; background: #fff; border: 1px solid var(--line); color: var(--ink); overflow-wrap: anywhere; }
.drive-status { display: grid; gap: 5px; color: var(--muted); }
.hidden { display: none !important; }
.empty { padding: 20px; color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #1f2933; color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(18px); transition: .18s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.error { color: #ad3f59; min-height: 22px; }

.login-page { display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(460px, 100%); }
.login-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.login-panel .brand-row p { color: var(--muted); }
.login-form { display: grid; gap: 12px; }
.login-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; font-size: 13px; }
.demo-users { display: grid; gap: 5px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 14px; }
.demo-users strong { color: var(--ink); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .roles { grid-template-columns: repeat(2, minmax(170px, 1fr)); }
  .photo-slot-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; padding: 12px; }
  .nav { display: flex; overflow-x: auto; }
  .nav-btn, .logout { flex: 0 0 auto; }
  .main { padding: 14px; }
  .filters, .info-grid, .roles { grid-template-columns: 1fr; }
  .report-subtype { grid-template-columns: 1fr; }
  .photo-slot-grid { grid-template-columns: 1fr; }
}
