:root {
  color-scheme: light;
  --ink: #14201d;
  --muted: #60716d;
  --line: #dce4e1;
  --paper: #f5f8f7;
  --white: #ffffff;
  --green-950: #0d2825;
  --green-900: #173f3a;
  --green-800: #1f554e;
  --green-700: #27685f;
  --green-100: #e5f2ee;
  --mint: #f0f8f5;
  --amber: #e3a436;
  --red: #b94b43;
  --blue: #2d75a2;
  --shadow: 0 18px 55px rgba(20, 32, 29, 0.1);
  --soft-shadow: 0 1px 2px rgba(20, 32, 29, 0.06), 0 16px 44px rgba(20, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(227, 164, 54, 0.11), transparent 34vw),
    linear-gradient(180deg, #fbfcfb 0%, var(--paper) 36%);
  line-height: 1.5;
}

button,
input,
select {
  font-family: "Noto Sans Thai", sans-serif;
  font-size: inherit;
}

button {
  cursor: pointer;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 70% 18%, rgba(227, 164, 54, 0.26), transparent 24vw),
    radial-gradient(circle at 20% 80%, rgba(45, 117, 162, 0.28), transparent 22vw),
    linear-gradient(135deg, var(--green-950), var(--green-900));
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: clamp(24px, 4vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.login-card .brand-mark {
  background: var(--green-900);
}

.login-card h1 {
  font-size: clamp(28px, 4vw, 36px);
}

.login-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-error {
  min-height: 22px;
  color: var(--red);
  font-weight: 800;
}

.demo-account {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 13px;
}

.credential-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.credential-row span {
  color: var(--muted);
  font-weight: 800;
}

.credential-row code {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-family: "Noto Sans Thai", sans-serif;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.app-shell.is-locked {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  color: var(--white);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 38%),
    var(--green-950);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(227, 164, 54, 0.12);
  color: #ffd884;
  font-weight: 800;
}

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

.brand small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.side-nav a span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffd884;
  font-size: 13px;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

.side-nav a.active {
  box-shadow: inset 3px 0 0 var(--amber);
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.logout-button {
  width: 100%;
  min-height: 38px;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  font-weight: 800;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px clamp(22px, 3vw, 38px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid rgba(220, 228, 225, 0.8);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(240, 248, 245, 0.9)),
    var(--white);
  box-shadow: var(--soft-shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: 0;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.title-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.title-meta strong {
  color: var(--green-900);
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(20, 32, 29, 0.04);
}

.button.primary {
  width: 100%;
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  color: var(--white);
}

.button.secondary {
  background: var(--white);
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost {
  background: linear-gradient(135deg, var(--green-900), var(--green-800));
  color: var(--white);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.quick-actions a {
  display: grid;
  grid-template-columns: 46px 1fr;
  column-gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 1px 0 rgba(20, 32, 29, 0.04);
}

.quick-actions a:hover {
  border-color: rgba(39, 104, 95, 0.35);
  box-shadow: var(--soft-shadow);
}

.quick-actions span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 800;
}

.quick-actions strong,
.quick-actions small {
  display: block;
}

.quick-actions small {
  color: var(--muted);
}

.billing-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.billing-summary article {
  min-height: 108px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--mint), var(--green-100));
}

.billing-summary small,
.billing-summary strong {
  display: block;
}

.billing-summary small {
  color: var(--muted);
}

.billing-summary strong {
  margin-top: 8px;
  color: var(--green-900);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.summary-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 1px 0 rgba(20, 32, 29, 0.03);
}

.summary-card {
  min-height: 138px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 14px auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(39, 104, 95, 0.08);
}

.summary-card.primary {
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: var(--white);
}

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

.summary-card.primary strong {
  color: var(--white);
}

.summary-card small,
.summary-card span {
  display: block;
  color: var(--muted);
}

.summary-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--green-900);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1;
}

.summary-card.warn strong {
  color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.82fr) minmax(0, 1.18fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
  min-width: 0;
}

.panel.elevated,
.chart-panel {
  box-shadow: var(--soft-shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading span,
.panel-heading a {
  color: var(--muted);
  font-size: 13px;
}

.panel-heading a {
  color: var(--green-700);
  font-weight: 800;
}

.form-panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

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

input:focus,
select:focus {
  outline: 3px solid rgba(39, 104, 95, 0.14);
  border-color: var(--green-700);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview-box {
  padding: 14px;
  border: 1px solid rgba(39, 104, 95, 0.14);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green-100), #f7fbf9);
}

.preview-box span,
.preview-box strong {
  display: block;
}

.preview-box span {
  color: var(--muted);
  font-size: 13px;
}

.preview-box strong {
  margin-top: 4px;
  color: var(--green-900);
  font-size: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfdfc;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.normal {
  background: var(--green-100);
  color: var(--green-900);
}

.status.watch {
  background: #fff0cf;
  color: #8b5b00;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--green-700);
  font-weight: 800;
}

.text-button.danger {
  color: var(--red);
}

.bar-chart {
  display: grid;
  gap: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px 1fr 88px;
  gap: 12px;
  align-items: center;
}

.bar-row span {
  color: var(--muted);
  font-weight: 800;
}

.bar-row strong {
  text-align: right;
}

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

.bar-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-700), var(--blue));
}

.inline-filter {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.inline-filter input {
  width: 168px;
}

.app-footer {
  margin-top: auto;
  padding: 18px 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
  }

  .sidebar-note {
    display: none;
  }

  .summary-grid,
  .quick-actions,
  .billing-summary,
  .content-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .top-actions,
  .billing-summary,
  .quick-actions,
  .summary-grid,
  .content-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .content-grid {
    display: grid;
  }

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

  .bar-row strong {
    grid-column: 2;
    text-align: left;
  }
}
