:root {
  --pea-purple: #5a2a82;
  --pea-purple-dark: #351551;
  --pea-purple-soft: #efe6f6;
  --pea-gold: #f6b01a;
  --pea-gold-soft: #fff2cf;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --bg: #f6f7fb;
  --danger: #c83232;
  --ok: #16845d;
  --warn: #b77900;
  font-family: "Kanit", "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  max-width: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(246, 176, 26, 0.22), transparent 30rem),
    linear-gradient(135deg, #fbfcff 0%, var(--bg) 52%, #f3eff8 100%);
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  padding: 24px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(90, 42, 130, 0.98), rgba(53, 21, 81, 0.98)),
    var(--pea-purple);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.brand img {
  width: 52px;
  height: 52px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 19px;
}

.brand span,
.sidebar-card small {
  color: rgba(255, 255, 255, 0.72);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 36px;
}

.nav a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
}

.nav a.active,
.nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.sidebar-card {
  display: grid;
  gap: 7px;
  margin-top: 34px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.integration-card strong {
  font-size: 24px;
}

.integration-card.online strong {
  color: #7ee7bd;
}

.integration-card.error strong {
  color: #ffb4b4;
}

.sidebar-card span {
  color: rgba(255, 255, 255, 0.72);
}

.sidebar-card strong {
  font-size: 34px;
  color: var(--pea-gold);
}

.workspace {
  width: min(1440px, 100%);
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.budget-switch-wrap {
  min-width: 220px;
}

.budget-switch-wrap label {
  gap: 6px;
}

.sidebar-budget-switch {
  margin-top: 22px;
  margin-bottom: 18px;
}

.sidebar-budget-switch label {
  color: #fff;
}

.sidebar-budget-switch select {
  color: #fff;
  font-weight: 700;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-budget-switch select:focus {
  border-color: var(--pea-gold);
}

.sidebar-budget-switch option {
  color: var(--ink);
  background: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--pea-purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 42px);
}

h2 {
  font-size: 21px;
}

.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button {
  padding: 0 16px;
  color: var(--pea-purple);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.delete-row-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--danger);
  border: 1px solid #f4b4b4;
  border-radius: 8px;
  background: #fff5f5;
  cursor: pointer;
  font-weight: 800;
}

.delete-row-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--pea-purple), #7f45ad);
  box-shadow: 0 14px 28px rgba(90, 42, 130, 0.22);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 51, 0.48);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(100%, 480px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(228, 231, 236, 0.9);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(23, 32, 51, 0.24);
}

.confirm-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.confirm-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.confirm-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f9fafb;
}

.confirm-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.confirm-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.confirm-actions .primary-button,
.confirm-actions .ghost-button {
  width: 100%;
}

.hero-panel,
.integration-panel,
.entry-panel,
.chart-panel,
.category-panel,
.table-panel,
.kpi-grid article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 51, 0.08);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: center;
  gap: 24px;
  min-height: 220px;
  padding: 30px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(90, 42, 130, 0.95), rgba(80, 38, 116, 0.88)),
    var(--pea-purple);
  color: #fff;
}

.integration-panel {
  padding: 20px;
  margin-bottom: 18px;
}

.integration-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: end;
  gap: 14px;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-hint {
  margin-bottom: 18px;
  padding: 12px 14px;
  color: #69410a;
  border: 1px solid #efd7a5;
  border-radius: 8px;
  background: #fff7e2;
}

.hero-copy p,
.hero-copy span,
.hero-meter span {
  color: rgba(255, 255, 255, 0.72);
}

.hero-copy p {
  margin: 0 0 8px;
}

.hero-copy strong {
  display: block;
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.05;
}

.hero-meter {
  position: relative;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
}

.hero-meter svg,
.hero-meter > div {
  grid-area: 1 / 1;
}

.hero-meter > div {
  display: grid;
  place-items: center;
}

.hero-meter strong {
  font-size: 34px;
  color: var(--pea-gold);
}

.hero-meter circle {
  fill: none;
  stroke-width: 18;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.meter-track {
  stroke: rgba(255, 255, 255, 0.16);
}

.meter-value {
  stroke: var(--pea-gold);
  stroke-linecap: round;
  stroke-dasharray: 540;
  stroke-dashoffset: 540;
  transition: stroke-dashoffset 0.4s ease;
}

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

.kpi-grid article {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 18px;
  overflow: hidden;
  background: #fff;
}

.kpi-grid span,
.claim-preview span,
.bar-label span,
.category-card span {
  color: var(--muted);
}

.kpi-grid strong {
  font-size: 27px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(0, 1.12fr);
  gap: 18px;
}

.entry-panel,
.chart-panel,
.category-panel,
.table-panel {
  padding: 20px;
}

.entry-panel {
  position: relative;
  overflow: hidden;
  border-color: var(--line);
  background: #fff;
  box-shadow:
    0 22px 58px rgba(90, 42, 130, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.entry-panel .section-title,
.entry-panel .form-grid,
.entry-panel .claim-preview,
.entry-panel .primary-button {
  position: relative;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill {
  padding: 7px 11px;
  color: var(--ok);
  border-radius: 999px;
  background: #e8f6f1;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.danger {
  color: var(--danger);
  background: #fdecec;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

label.wide {
  grid-column: 1 / -1;
}

.date-range-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  color: var(--ink);
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(246, 176, 26, 0.24);
  border-color: var(--pea-gold);
}

.claim-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.claim-preview div {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(90, 42, 130, 0.12);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(90, 42, 130, 0.08);
}

.claim-preview strong {
  font-size: 22px;
}

.claim-preview .danger strong {
  color: var(--danger);
}

.bar-chart {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.bar-header-row {
  display: grid;
  grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) 96px;
  align-items: end;
  gap: 12px;
}

.bar-header-row span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) 96px;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.bar-label {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bar-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #eaecf0;
}

.bar-fill {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pea-purple), var(--pea-gold));
}

.bar-value {
  display: grid;
  gap: 4px;
  text-align: right;
}

.bar-value strong {
  font-weight: 800;
}

.bar-value span {
  color: var(--muted);
  font-size: 12px;
}

.category-panel,
.table-panel {
  margin-top: 18px;
}

.search-box {
  max-width: 250px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  gap: 14px;
}

.category-card {
  display: grid;
  gap: 12px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.category-head strong {
  line-height: 1.35;
}

.badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ok);
  background: #e8f6f1;
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  color: var(--warn);
  background: var(--pea-gold-soft);
}

.badge.danger {
  color: var(--danger);
  background: #fdecec;
}

.mini-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eaecf0;
}

.mini-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--pea-purple);
}

.category-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 13px;
}

.category-numbers strong {
  display: block;
  margin-top: 2px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 13px;
}

td:last-child,
td:nth-child(6),
td:nth-child(7),
th:last-child,
th:nth-child(6),
th:nth-child(7) {
  text-align: right;
}

.action-column,
.action-cell {
  width: 92px;
  text-align: right;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .category-grid,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px 16px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
  }

  .sidebar-card {
    margin-top: 18px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .budget-switch-wrap {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions .ghost-button {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    padding: 22px 18px;
  }

  .hero-meter {
    justify-self: center;
    width: 180px;
    height: 180px;
  }

  .hero-meter strong {
    font-size: 30px;
  }

  .hero-copy strong {
    font-size: 42px;
  }

  .form-grid,
  .integration-grid,
  .claim-preview,
  .category-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .date-range-inputs {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-header-row {
    display: none;
  }

  .bar-value {
    text-align: left;
  }

  .search-box {
    max-width: none;
    width: 100%;
  }

  table {
    min-width: 760px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 16px 14px;
  }

  .workspace {
    padding: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand img {
    width: 44px;
    height: 44px;
  }

  .brand strong {
    font-size: 17px;
  }

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

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  .topbar-actions .ghost-button,
  .section-title .ghost-button,
  .primary-button {
    width: 100%;
  }

  .confirm-dialog {
    padding: 18px;
  }

  .confirm-list div,
  .confirm-actions {
    grid-template-columns: 1fr;
  }

  .hero-panel,
  .entry-panel,
  .chart-panel,
  .category-panel,
  .table-panel,
  .integration-panel {
    padding: 16px;
  }

  .section-title > div,
  .topbar > div,
  .bar-label,
  .bar-value,
  .category-head > div {
    min-width: 0;
  }

  .hero-copy strong {
    font-size: 36px;
  }

  .hero-meter {
    width: 156px;
    height: 156px;
  }

  .hero-meter strong {
    font-size: 26px;
  }

  .kpi-grid strong {
    font-size: 24px;
  }

  .claim-preview strong {
    font-size: 20px;
  }

  .category-card {
    min-height: 0;
  }

  table {
    min-width: 620px;
  }
}
