:root {
  --bg: #f4f7fb;
  --sidebar: #0d2b45;
  --sidebar-soft: #173c5c;
  --sidebar-text: #d8e2ee;
  --card: #ffffff;
  --card-soft: #f8fbff;
  --line: #e5e7eb;
  --line-soft: #eef2f7;
  --text: #172033;
  --muted: #6b7280;
  --green: #22c55e;
  --green-dark: #15803d;
  --green-soft: #e9f9ef;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", "Trebuchet MS", sans-serif;
}

a { color: inherit; }

.auth-body {
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.08), transparent 32%),
    linear-gradient(180deg, #eef4fb 0%, #f4f7fb 58%);
}

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

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.14);
  color: #ecfdf5;
  font-size: 20px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark-large {
  width: 54px;
  height: 54px;
  font-size: 26px;
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: rgba(34, 197, 94, 0.2);
}

.brand-copy { min-width: 0; }
.brand-name { font-size: 22px; font-weight: 800; color: #ffffff; }
.brand-tagline { font-size: 12px; color: rgba(216, 226, 238, 0.74); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-note {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(216, 226, 238, 0.82);
  font-size: 12px;
}

.nav-link {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--sidebar-text);
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-link.active {
  background: rgba(34, 197, 94, 0.16);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.16);
}

.sidebar-logout {
  margin-top: auto;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-copy h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.15;
}

.page-copy p {
  margin: 4px 0 0;
  color: var(--muted);
}

.page-kicker {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

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

.env-badge,
.user-chip,
.status-pill {
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #ffffff;
}

.env-badge {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.user-chip {
  color: #334155;
}

.content-shell {
  padding: 26px 28px 30px;
}

.page-stack {
  display: grid;
  gap: 18px;
}

.surface {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.surface-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.surface-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.surface-copy {
  margin: 4px 0 0;
  color: var(--muted);
}

.table-caption {
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.form-actions-end {
  justify-content: flex-end;
}

.kpi-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-value {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
}

.kpi-success .kpi-value { color: var(--green-dark); }
.kpi-danger .kpi-value { color: var(--danger); }

.metric-strip {
  display: grid;
  gap: 12px;
}

.metric-strip-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-strip-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.metric-cell {
  min-height: 84px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--card-soft);
  padding: 14px 16px;
}

.metric-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-cell b {
  display: block;
  margin-top: 10px;
  font-size: 20px;
  line-height: 1.2;
}

.progress-block {
  margin-top: 14px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

.two-column-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.filters-grid,
.editor-grid,
.danger-grid {
  display: grid;
  gap: 12px;
}

.filters-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.editor-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.danger-grid {
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: end;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.field-span-2 { grid-column: span 2; }
.field-span-3 { grid-column: span 3; }
.field-span-4 { grid-column: span 4; }

input,
select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.btn {
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  background: #f8fafc;
  color: var(--text);
}

.btn:hover { filter: brightness(0.98); }

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-danger {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: #991b1b;
}

.btn-ghost {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-block { width: 100%; }

.btn-small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.data-table th {
  height: 36px;
  padding: 0 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.data-table td.actions-cell,
.data-table td.role-form-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #f9fbfd;
}

.center { text-align: center; }
.money { text-align: right; font-variant-numeric: tabular-nums; }
.danger-text { color: var(--danger); font-weight: 700; }

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

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.table-actions-stack {
  display: grid;
  gap: 8px;
  justify-items: start;
}

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

.inline-form-centered {
  justify-content: center;
}

.inline-select {
  min-width: 110px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
}

.inline-input {
  min-width: 180px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
}

.muted-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.actions form {
  margin: 0;
}

.status-pill {
  background: #eff6ff;
  border-color: #dbeafe;
  color: #1d4ed8;
}

.status-pill.kirim,
.status-pill.active {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: var(--green-dark);
}

.status-pill.chiqim,
.status-pill.overdue,
.status-pill.cancelled,
.status-pill.unpaid {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.status-pill.paid,
.status-pill.closed {
  background: #eefcf4;
  border-color: #bbf7d0;
  color: var(--green-dark);
}

.empty {
  height: 84px;
  text-align: center;
  color: var(--muted);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash-message {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 11px 14px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.flash-message.error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: #991b1b;
}

.flash-message.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.danger-panel {
  border-color: var(--danger-line);
  background: linear-gradient(180deg, #fff8f8 0%, #ffffff 100%);
}

.note-panel {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--card-soft);
  padding: 14px 16px;
  color: var(--muted);
}

.auth-main {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.auth-flash {
  width: min(460px, 100%);
  margin: 0 auto 16px;
}

.login-shell {
  width: 100%;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 48px rgba(13, 43, 69, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.login-copy h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

.login-copy p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

@media (max-width: 1366px) {
  .kpi-grid-five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1160px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
  .sidebar-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { padding: 16px 18px; }
  .content-shell { padding: 18px; }
  .kpi-grid-five,
  .kpi-grid-four,
  .kpi-grid-three,
  .two-column-layout,
  .metric-strip-five,
  .metric-strip-three,
  .filters-grid,
  .editor-grid-3,
  .editor-grid-4,
  .danger-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field-span-2,
  .field-span-3,
  .field-span-4 {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .sidebar-nav,
  .kpi-grid-five,
  .kpi-grid-four,
  .kpi-grid-three,
  .two-column-layout,
  .metric-strip-five,
  .metric-strip-three,
  .filters-grid,
  .editor-grid-3,
  .editor-grid-4,
  .danger-grid {
    grid-template-columns: 1fr;
  }
  .field-span-2,
  .field-span-3,
  .field-span-4 {
    grid-column: span 1;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
