:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --text: #1d2733;
  --muted: #607083;
  --line: #d9e1ea;
  --teal: #0f766e;
  --teal-soft: #d9f4ef;
  --amber: #d97706;
  --amber-soft: #fff2cf;
  --blue: #2563eb;
  --blue-soft: #e6efff;
  --coral: #e85d4f;
  --coral-soft: #ffe6e2;
  --green: #16803f;
  --green-soft: #ddf7e7;
  --shadow: 0 16px 40px rgba(30, 43, 58, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--bg);
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

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

.login-brand strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.login-brand span {
  color: var(--muted);
  margin-top: 2px;
  font-size: 13px;
}

.login-card h1 {
  margin: 2px 0 0;
  font-size: 30px;
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-card input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.login-card input:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.login-switch {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--teal);
  font-weight: 800;
  text-align: center;
}

.login-switch:hover,
.login-switch:focus-visible {
  background: var(--teal-soft);
  outline: 0;
}

.login-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.login-message.error {
  color: var(--coral);
  font-weight: 800;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 16px;
  background: #102126;
  color: #f6fafb;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  border-right: 1px solid #1f363b;
}

.sidebar-toggle {
  position: absolute;
  top: 20px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #eaf3f5;
  display: grid;
  place-items: center;
  padding: 0;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  border-color: #eef9f5;
  outline: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding-right: 42px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f6c85f;
  color: #121517;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand strong {
  display: block;
  color: #f6fafb;
  font-size: 16px;
}

.brand span {
  display: block;
  color: #a7b5c3;
  font-size: 13px;
  margin-top: 2px;
}

.user-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.user-chip strong,
.user-chip span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip strong {
  color: #f6fafb;
  font-size: 13px;
  line-height: 1.25;
}

.user-chip span {
  color: #a7b5c3;
  font-size: 12px;
  margin-top: 2px;
}

.user-chip button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #eaf3f5;
  display: grid;
  place-items: center;
  padding: 0;
}

.user-chip button:hover,
.user-chip button:focus-visible {
  border-color: #eef9f5;
  outline: 0;
}

.user-chip svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-nav button {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 12px;
  text-align: left;
  background: transparent;
  color: #d9e6f5;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.sidebar-nav .icon {
  width: 18px;
  height: 18px;
}

.sidebar-nav .icon svg {
  width: 18px;
  height: 18px;
}

.menu-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav button:hover,
.sidebar-nav button:focus-visible {
  color: #ffffff;
  border-color: rgba(238, 249, 245, 0.18);
  background: rgba(255, 255, 255, 0.06);
  outline: 0;
}

.sidebar-nav button.active {
  color: #102126;
  background: #eef9f5;
}

.app-shell.menu-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.app-shell.menu-collapsed .sidebar {
  padding: 18px 10px;
  align-items: center;
  gap: 18px;
}

.app-shell.menu-collapsed .brand-copy {
  display: none;
}

.app-shell.menu-collapsed .user-chip {
  width: 44px;
  min-height: 44px;
  grid-template-columns: 1fr;
  padding: 4px;
}

.app-shell.menu-collapsed .user-chip div {
  display: none;
}

.app-shell.menu-collapsed .brand {
  padding-right: 0;
  justify-content: center;
  min-height: 42px;
  width: 100%;
}

.app-shell.menu-collapsed .sidebar-toggle {
  position: static;
  order: 3;
  width: 40px;
  height: 40px;
  margin-top: 4px;
}

.app-shell.menu-collapsed .sidebar-nav {
  width: 100%;
  gap: 10px;
}

.app-shell.menu-collapsed .sidebar-nav button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0 auto;
  padding: 0;
  color: #abc1c6;
  display: grid;
  place-items: center;
  text-align: center;
  position: relative;
}

.app-shell.menu-collapsed .sidebar-nav button::before {
  display: none;
}

.app-shell.menu-collapsed .sidebar-nav .menu-label {
  display: none;
}

.app-shell.menu-collapsed .sidebar-nav .icon,
.app-shell.menu-collapsed .sidebar-nav .icon svg {
  width: 20px;
  height: 20px;
}

.app-shell.menu-collapsed .sidebar-nav button.active {
  color: var(--teal);
  background: #eef9f5;
}

.app-shell.menu-collapsed .sidebar-nav button.active::before {
  display: none;
}

.year-control {
  display: grid;
  gap: 8px;
}

.year-control label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.year-actions {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 8px;
}

.year-actions button,
.year-actions input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

.year-actions button {
  display: grid;
  place-items: center;
  padding: 0;
}

.year-actions input {
  width: 100%;
  text-align: center;
  font-weight: 800;
  outline: 0;
}

.year-actions button:hover,
.year-actions button:focus-visible,
.year-actions input:focus {
  border-color: var(--teal);
  outline: 0;
}

.period-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.period-nav button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.period-nav button.active {
  background: var(--teal-soft);
  border-color: #a8ded4;
  color: var(--teal);
  font-weight: 800;
}

.period-nav small {
  color: inherit;
  opacity: 0.7;
}

.source-box {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 5px;
}

.source-box span,
.source-box small {
  color: #abc1c6;
}

.source-box small {
  word-break: break-word;
}

.period-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.period-panel-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 280px);
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
}

.period-panel h2 {
  margin-bottom: 5px;
}

.period-panel small {
  color: var(--muted);
}

.period-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.period-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.period-meta strong {
  font-size: 17px;
}

.page-block[hidden] {
  display: none !important;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

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

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

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.1;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

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

.search-box,
.tool-button,
.primary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  width: min(320px, 100%);
  padding: 0 12px;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.tool-button,
.primary-button {
  padding: 0 14px;
  color: var(--text);
}

.tool-button:hover,
.tool-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.segmented button:hover,
.segmented button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.tool-button.ghost {
  background: transparent;
}

.file-input {
  display: none;
}

.primary-button {
  justify-content: center;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 800;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-row {
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #a8ded4;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.05;
  word-break: break-word;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(260px, 0.85fr) minmax(250px, 0.8fr);
  gap: 14px;
  margin-bottom: 18px;
}

.chart-panel,
.entry-panel,
.product-panel,
.capital-panel,
.database-panel,
.settings-panel,
.control-panel,
.help-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.legend span,
.status-list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i,
.status-list i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-sale {
  background: var(--blue);
}

.legend-profit {
  background: var(--amber);
}

#revenueChart {
  display: block;
  width: 100%;
  max-width: 100%;
}

#statusChart {
  display: block;
  width: 180px;
  height: 180px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.status-list,
.customer-list {
  display: grid;
  gap: 10px;
}

.status-list div,
.customer-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
}

.customer-item strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-item span {
  flex: 0 0 auto;
}

.panel-total {
  color: var(--muted);
  font-size: 13px;
}

.entry-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.product-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.capital-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.database-panel,
.settings-panel,
.control-panel,
.help-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.form-head span {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-soft);
  font-weight: 800;
}

.entry-previews {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.field-package,
.form-grid label:nth-child(2) {
  grid-column: span 2;
}

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

.form-grid label span,
.form-grid .form-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-grid input,
.form-grid select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.price-field input[readonly] {
  color: var(--muted);
  background: #edf4f3;
}

.product-combobox {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  min-width: 0;
}

.product-combobox input[type="search"] {
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.product-combo-toggle {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: var(--surface-strong);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.product-combo-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product-combobox.open input[type="search"],
.product-combobox:focus-within input[type="search"],
.product-combobox.open .product-combo-toggle,
.product-combobox:focus-within .product-combo-toggle {
  border-color: var(--teal);
  background: #ffffff;
}

.product-combo-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: min(340px, 62vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 36px rgba(16, 33, 38, 0.16);
}

.product-combo-group {
  padding: 8px;
  border-top: 1px solid #edf2f5;
}

.product-combo-group:first-child {
  border-top: 0;
}

.product-combo-group-title {
  padding: 5px 7px 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.product-combo-option {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  padding: 8px 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 3px;
  cursor: pointer;
}

.product-combo-option:hover,
.product-combo-option:focus-visible,
.product-combo-option.active {
  outline: 0;
  background: var(--teal-soft);
  color: var(--teal);
}

.product-combo-option span {
  font-weight: 800;
  line-height: 1.25;
}

.product-combo-option small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.product-combo-option.active small {
  color: var(--teal);
}

.product-combo-empty {
  padding: 14px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.product-form-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(150px, 0.9fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) 160px 92px;
  gap: 10px;
  align-items: end;
}

.product-form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.product-form-grid label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-form-grid input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.product-form-grid input:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.product-list {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.product-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.product-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 126, 112, 0.1), rgba(255, 255, 255, 0.78));
  padding: 12px 14px;
}

.product-group-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.product-group-head span,
.product-group-head strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-group-head strong {
  color: var(--teal);
  white-space: nowrap;
}

.product-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 10px;
}

.product-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.product-main {
  grid-column: 1 / -1;
  min-width: 0;
}

.product-main strong,
.product-main span {
  display: block;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.product-main strong {
  color: var(--text);
  line-height: 1.25;
}

.product-category {
  width: fit-content;
  max-width: 100%;
  margin-top: 7px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.product-prices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 7px;
}

.product-prices span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.product-prices b {
  color: var(--text);
  font-weight: 800;
}

.product-profit {
  color: var(--teal);
  font-weight: 800;
  white-space: nowrap;
  display: grid;
  gap: 2px;
  align-self: center;
}

.product-profit small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.product-profit strong {
  font-size: 16px;
  line-height: 1.1;
}

.product-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-self: center;
}

.product-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 9px;
}

.product-actions button:hover,
.product-actions button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.product-actions button.danger:hover,
.product-actions button.danger:focus-visible {
  border-color: var(--coral);
  color: var(--coral);
}

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

.capital-card {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.capital-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.capital-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.capital-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.capital-card.warning strong {
  color: var(--coral);
}

.form-head span.warning {
  color: var(--coral);
  background: var(--coral-soft);
}

.capital-form-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(150px, 0.7fr) minmax(170px, 0.8fr) minmax(220px, 1.2fr) 160px;
  gap: 10px;
  align-items: end;
}

.capital-form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.capital-form-grid label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.capital-form-grid input,
.capital-form-grid select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.capital-form-grid input:focus,
.capital-form-grid select:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.capital-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.capital-list-head h2 {
  margin: 0;
  font-size: 16px;
}

.capital-list-head span {
  color: var(--muted);
  font-size: 13px;
}

.capital-list {
  display: grid;
  gap: 8px;
}

.capital-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 11px;
}

.capital-item strong,
.capital-item span,
.capital-item small {
  display: block;
}

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

.capital-item strong {
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.capital-item .capital-money {
  color: var(--teal);
  font-weight: 900;
  white-space: nowrap;
}

.capital-item button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 9px;
}

.capital-item button:hover,
.capital-item button:focus-visible {
  border-color: var(--coral);
  color: var(--coral);
  outline: 0;
}

.database-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.database-actions button {
  min-width: 170px;
  justify-content: center;
}

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

.brand-settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) repeat(2, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

.brand-settings-grid label,
.brand-file {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.brand-settings-grid label span,
.brand-file > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.brand-settings-grid input,
.brand-file input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.brand-settings-grid input:focus,
.brand-file input:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.brand-preview-card {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-preview-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  background: #f6c85f;
  color: #121517;
  font-size: 18px;
  font-weight: 900;
}

.brand-preview-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-preview-card strong,
.brand-preview-card span {
  display: block;
  overflow-wrap: anywhere;
}

.brand-preview-card strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.brand-preview-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.brand-upload-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.brand-file small {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.account-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: stretch;
}

.account-card {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.account-card small,
.account-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-card strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) 160px;
  gap: 10px;
  align-items: end;
}

.control-form {
  grid-template-columns: repeat(5, minmax(130px, 1fr)) 170px;
  margin-bottom: 14px;
}

.user-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.user-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-form input,
.user-form select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.user-form input:focus,
.user-form select:focus {
  border-color: var(--teal);
  background: #ffffff;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.user-list-item {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.user-list-item.active {
  border-color: #98ddd2;
  background: var(--teal-soft);
}

.user-list-item strong,
.user-list-item span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-list-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.user-list-item small {
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf4f3;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  align-self: center;
}

.user-list-item small.superuser {
  background: var(--amber-soft);
  color: var(--amber);
}

.user-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 9px;
}

.user-actions button:hover,
.user-actions button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.user-actions button.danger:hover,
.user-actions button.danger:focus-visible {
  border-color: var(--coral);
  color: var(--coral);
}

.control-user-list .user-list-item {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 0.65fr) auto;
  align-items: end;
}

.control-owner-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.control-owner-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.control-owner-field select {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 9px;
}

.database-notes,
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.database-notes div,
.help-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.database-notes strong,
.help-grid strong {
  display: block;
  margin-bottom: 6px;
}

.database-notes span,
.help-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.table-panel {
  overflow: hidden;
}

.table-panel .panel-head {
  padding: 16px 16px 0;
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
}

th button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font-weight: 800;
}

td {
  font-size: 14px;
}

.period-cell {
  display: block;
  color: var(--text);
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.money,
.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 701px) {
  .table-panel th,
  .table-panel td,
  .table-panel .money,
  .table-panel .number {
    text-align: center;
  }

  .table-panel .row-actions {
    justify-content: center;
  }
}

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

.status-lunas {
  background: var(--green-soft);
  color: var(--green);
}

.status-belum-lunas {
  background: var(--coral-soft);
  color: var(--coral);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 9px;
}

.row-actions button:hover,
.row-actions button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.row-actions button.danger:hover,
.row-actions button.danger:focus-visible {
  border-color: var(--coral);
  color: var(--coral);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #102126;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(16, 33, 38, 0.48);
}

.modal.show {
  display: grid;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 33, 38, 0.22);
  padding: 16px;
  display: grid;
  gap: 14px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  display: grid;
  place-items: center;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

#backupText {
  width: 100%;
  min-height: 330px;
  max-height: 52vh;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  outline: 0;
}

#backupText:focus {
  border-color: var(--teal);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

  .insight-grid .chart-panel:first-child {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .product-form-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .capital-summary {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .control-summary {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .capital-form-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .brand-settings-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .account-grid,
  .user-form {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .control-user-list .user-list-item {
    grid-template-columns: 1fr;
  }

  .account-card {
    grid-column: 1 / -1;
  }

  .brand-preview-card {
    grid-column: 1 / -1;
  }

  .field-package,
  .form-grid label:nth-child(2) {
    grid-column: span 1;
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    max-height: none;
    padding: 14px;
    gap: 12px;
    box-shadow: 0 16px 34px rgba(16, 33, 38, 0.2);
  }

  .brand {
    min-height: 44px;
    padding-right: 56px;
  }

  .user-chip {
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .sidebar-toggle {
    top: 14px;
    right: 14px;
  }

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

  .app-shell.menu-open .sidebar-nav {
    display: grid;
  }

  .app-shell.menu-collapsed .sidebar {
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .app-shell.menu-collapsed .brand {
    justify-content: flex-start;
    padding-right: 56px;
    min-height: 44px;
  }

  .app-shell.menu-collapsed .brand-copy {
    display: block;
  }

  .app-shell.menu-collapsed .user-chip {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 40px;
    padding: 8px;
  }

  .app-shell.menu-collapsed .user-chip div {
    display: block;
  }

  .app-shell.menu-collapsed .sidebar-toggle {
    position: absolute;
    top: 14px;
    right: 14px;
    order: 0;
    margin-top: 0;
  }

  .app-shell.menu-collapsed .sidebar-nav button {
    width: 100%;
    height: auto;
    min-height: 42px;
    padding: 0 12px;
    color: #d9e6f5;
    display: flex;
    justify-content: flex-start;
    text-align: left;
  }

  .app-shell.menu-collapsed .sidebar-nav button.active {
    color: #102126;
  }

  .app-shell.menu-collapsed .sidebar-nav .menu-label {
    display: block;
  }

  .app-shell.menu-collapsed .sidebar-nav .icon,
  .app-shell.menu-collapsed .sidebar-nav .icon svg {
    width: 18px;
    height: 18px;
  }

  .period-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .period-nav button {
    flex: 0 0 154px;
    scroll-snap-align: start;
  }

  .period-panel-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .period-meta {
    justify-items: start;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: stretch;
  }

  .search-box {
    width: 100%;
    flex: 1 1 100%;
  }

  .tool-button {
    flex: 1 1 120px;
    justify-content: center;
  }

  .summary-grid,
  .insight-grid,
  .form-grid,
    .product-form-grid,
    .capital-summary,
    .capital-form-grid,
    .brand-settings-grid,
    .account-grid,
    .control-summary,
    .user-form {
    grid-template-columns: 1fr;
  }

  .account-card {
    grid-column: auto;
  }

  .brand-preview-card {
    grid-column: auto;
  }

  .brand-upload-row {
    grid-template-columns: 1fr 1fr;
  }

  .field-package,
  .form-grid label:nth-child(2) {
    grid-column: span 1;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

@media (max-width: 700px) {
  .login-screen {
    padding: 14px;
    align-items: start;
    padding-top: 28px;
  }

  .login-card {
    padding: 18px;
  }

  .table-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .table-panel .panel-head {
    padding: 14px 14px 0;
  }

  .table-wrap {
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    display: table;
    min-width: 980px;
    border-collapse: collapse;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  th,
  td {
    display: table-cell;
    width: auto;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    text-align: left;
  }

  .money,
  .number {
    text-align: right;
  }

  td::before {
    content: none;
  }

  .period-cell,
  td small {
    white-space: nowrap;
  }

  td[data-label="Nama"] {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    text-align: left;
  }

  .row-actions {
    width: max-content;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .row-actions button {
    min-height: 32px;
    padding: 0 10px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    position: static;
    padding: 12px;
  }

  .period-nav {
    margin-right: -14px;
    padding-right: 14px;
  }

  .period-nav button {
    flex-basis: 142px;
    padding: 10px;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 25px;
  }

  .eyebrow {
    font-size: 11px;
  }

  .toolbar {
    gap: 8px;
  }

  .search-box,
  .tool-button,
  .primary-button,
  .form-grid input,
  .form-grid select,
  .product-combo-toggle {
    min-height: 46px;
  }

  .status-row {
    margin-bottom: 12px;
    overflow-x: auto;
  }

  .segmented {
    display: inline-flex;
    flex-wrap: nowrap;
    min-width: max-content;
  }

  .segmented button {
    padding: 9px 11px;
  }

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

  .metric {
    min-height: 96px;
    padding: 12px;
  }

  .metric strong {
    font-size: 18px;
    line-height: 1.15;
  }

  .metric small {
    font-size: 12px;
  }

  .chart-panel,
  .entry-panel,
  .product-panel,
  .capital-panel,
  .database-panel,
  .settings-panel,
  .control-panel,
  .help-panel {
    padding: 14px;
  }

  .panel-head,
  .form-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .legend {
    width: 100%;
  }

  #revenueChart {
    min-height: 220px;
  }

  .form-head span {
    width: 100%;
    text-align: center;
  }

  .entry-previews {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .database-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .database-actions button {
    width: 100%;
  }

  .capital-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .capital-item .capital-money {
    white-space: normal;
  }

  .capital-item button {
    width: 100%;
    min-height: 38px;
  }

  .brand-upload-row {
    grid-template-columns: 1fr;
  }

  .brand-upload-row button {
    width: 100%;
  }

  .product-list {
    grid-template-columns: 1fr;
  }

  .product-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .product-main strong,
  .product-main span {
    white-space: normal;
  }

  .product-actions {
    justify-content: stretch;
  }

  .product-actions button {
    flex: 1 1 0;
    min-height: 38px;
  }

  .user-list-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-actions {
    justify-content: stretch;
  }

  .user-actions button {
    flex: 1 1 140px;
    min-height: 38px;
  }

  .modal {
    padding: 12px;
  }

  .modal-panel {
    padding: 14px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #backupText {
    min-height: 280px;
  }
}

@media (max-width: 360px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .tool-button {
    flex-basis: calc(50% - 4px);
  }

  td {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    text-align: left;
  }

  td::before {
    flex-basis: auto;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1 1 0;
  }
}
