:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --panel-soft: #f3f2ee;
  --text: #171717;
  --brand-wise: #a88748;
  --muted: #706f6a;
  --subtle: #3f3f3c;
  --border: #ddd9d2;
  --border-strong: #bdbbb4;
  --danger: #9f2d20;
  --danger-soft: #fff2ef;
  --success: #347a20;
  --success-soft: #effaf2;
  --focus-ring: rgba(23, 23, 23, 0.12);
  --shadow-sm: 0 1px 2px rgba(23, 23, 23, 0.04);
  --shadow-md: 0 14px 42px rgba(23, 23, 23, 0.06);
  --radius: 8px;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 90% 70% at 50% -8%, #ece8e0 0%, transparent 58%),
    radial-gradient(ellipse 55% 45% at 100% 100%, rgba(221, 217, 210, 0.45), transparent 52%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}

.brand-word {
  color: var(--text);
}

.brand-wise {
  color: var(--brand-wise);
  font-weight: 600;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-centered {
  justify-content: center;
  width: 100%;
  margin-bottom: 20px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.topbar .btn {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.topbar .btn:hover {
  background: var(--panel-soft);
  border-color: var(--text);
}

.main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 16px;
}

.list-page > .kpi-grid,
.list-page > .toolbar,
.list-page > .panel-header {
  flex-shrink: 0;
}

.list-page > .kpi-grid {
  margin-bottom: 0;
}

.list-page--reports {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}

.list-page--reports > .toolbar,
.list-page--reports > .panel,
.list-page--reports > .report-detail-region {
  flex-shrink: 0;
}

.list-page--reports .panel.panel--report-detail {
  flex: 0 0 auto;
  min-height: auto;
}

.list-page--reports .panel.panel--report-detail .table-scroll--flow {
  overflow: visible;
  flex: none;
  min-height: auto;
  max-height: none;
}

.list-page--reports .report-header-panel {
  overflow: visible;
}

.report-detail-region {
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 8px;
}

.report-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-detail-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.report-detail-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.report-detail-tab.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.report-detail-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.08);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.report-detail-tab.active .report-detail-tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.tab {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.tab.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.panel-header .btn {
  margin-left: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  flex: 1 1 420px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.toolbar .field {
  margin-bottom: 0;
  min-width: 200px;
}

.toolbar .field-grow {
  flex: 1 1 280px;
  min-width: 240px;
  max-width: 420px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel.panel--table {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

td.col-text,
th.col-text {
  text-align: left;
}

td.col-num,
th.col-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

td.col-actions,
th.col-actions {
  text-align: center;
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(243, 242, 238, 0.75);
}

tbody tr:last-child td {
  border-bottom: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.is-active {
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid #b8dcc0;
}

.status-pill.is-disabled {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #e2b8ae;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--text);
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  opacity: 0.86;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.86;
  background: var(--text);
  border-color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  opacity: 1;
  background: var(--panel-soft);
  border-color: transparent;
}

.topbar .btn {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.topbar .btn:hover:not(:disabled) {
  opacity: 1;
  background: var(--panel-soft);
  border-color: var(--text);
}

.btn-outline-danger {
  color: var(--danger);
  background: #fff;
  border-color: #e2b8ae;
}

.btn-outline-danger:hover:not(:disabled) {
  opacity: 1;
  background: var(--danger-soft);
  border-color: #ddb8b8;
}

.btn-success-outline {
  color: var(--success);
  border-color: #b8dcc0;
  background: #fff;
}

.btn-success-outline:hover:not(:disabled) {
  opacity: 1;
  background: var(--success-soft);
}

.login-card,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.login-card {
  width: min(400px, 100%);
  margin: 72px auto;
  border-radius: 14px;
  padding: 28px 28px 30px;
}

.login-card .brand {
  font-size: 22px;
  margin-bottom: 24px;
}

.login-card h1,
.modal-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.login-card p.muted,
.modal-card .modal-intro {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 13px;
  margin-top: 4px;
}

.login-form .field {
  margin-bottom: 0;
}

.login-form .btn-primary {
  width: 100%;
  min-height: 38px;
  margin-top: 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span,
.field-label {
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
}

.control,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.control:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

.field select,
select.control {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.form-actions,
.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.modal-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.hidden {
  display: none;
}

.error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #e2b8ae;
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.muted { color: var(--muted); }

.scope-panel {
  margin-top: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
  max-height: min(220px, 38vh);
  overflow-y: auto;
}

.scope-grid {
  display: grid;
  gap: 10px;
}

.scope-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.scope-option input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--text);
}

.confirm-modal {
  width: min(460px, 100%);
}

.confirm-modal h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.confirm-modal .modal-intro {
  margin-bottom: 0;
}

.confirm-modal .modal-footer {
  margin-top: 22px;
}

.modal-card .error {
  margin-top: 14px;
  margin-bottom: 0;
}

.modal-card .error.hidden {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(23, 23, 23, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 20px;
  overflow-y: auto;
}

.modal-card {
  width: min(520px, 100%);
  border-radius: 14px;
  padding: 24px;
  max-height: calc(100vh - 56px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: auto;
}

.modal-card-form {
  padding-bottom: 20px;
}

.modal-card h2 {
  flex-shrink: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.modal-body .field:last-child {
  margin-bottom: 0;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 14px;
}

.list-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.list-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel-soft);
  flex-shrink: 0;
}

.list-page-size {
  min-width: 108px;
  padding: 6px 10px;
  font-size: 13px;
}

.list-page-summary,
.list-page-indicator {
  font-size: 13px;
  color: var(--muted);
}

.list-page-indicator {
  margin-right: auto;
}

@media (max-width: 720px) {
  .main { padding: 16px; }
  .list-pagination {
    flex-wrap: wrap;
  }
  .list-page-indicator {
    order: 3;
    width: 100%;
    margin-right: 0;
  }
}

.report-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.report-metric-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.report-metric-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-metric-value {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.report-metric-hint {
  margin: 6px 0 0;
  font-size: 12px;
}

.report-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.report-breakdown h3,
.panel-section-head h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.report-breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.report-breakdown-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.report-breakdown-list li:last-child {
  border-bottom: 0;
}

.report-header-panel,
.report-empty-panel {
  padding: 18px;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.report-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.report-header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.report-footnote {
  margin: 14px 0 0;
  font-size: 12px;
}

.panel-section-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.panel-section-head .muted {
  margin: 0;
  font-size: 13px;
}

.list-page > .panel + .panel {
  margin-top: 0;
}

@media (max-width: 1100px) {
  .report-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .report-breakdown-grid,
  .report-metric-grid { grid-template-columns: minmax(0, 1fr); }
  .report-header { flex-direction: column; }
}

@media (max-width: 900px) {
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-actions {
    justify-content: flex-end;
    margin-left: 0;
  }
}

.modal-body,
.scope-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.modal-body::-webkit-scrollbar,
.scope-panel::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-thumb,
.scope-panel::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.scope-panel::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
