:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f1f5f4;
  --ink: #17211d;
  --muted: #68736e;
  --line: #dce4e0;
  --accent: #14746f;
  --accent-strong: #0b5f59;
  --warning: #b95c20;
  --danger: #b42318;
  --success: #157f3b;
  --shadow: 0 10px 26px rgba(16, 32, 28, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.eyebrow,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.panel p,
.metric-card small,
.side-summary small {
  color: var(--muted);
}

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

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.nav-item.active {
  border-color: rgba(20, 116, 111, 0.22);
  background: rgba(20, 116, 111, 0.1);
  color: var(--accent-strong);
  font-weight: 700;
}

.side-summary {
  margin-top: auto;
  display: grid;
  gap: 6px;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.side-summary strong {
  font-size: 25px;
}

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

.topbar,
.panel-header,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

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

.topbar h2 {
  margin-top: 5px;
  font-size: 28px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button,
.file-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 700;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(20, 116, 111, 0.18);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.file-button,
.icon-button {
  background: #fff;
  color: var(--ink);
}

.ghost-button:hover,
.file-button:hover,
.icon-button:hover {
  border-color: rgba(20, 116, 111, 0.34);
  background: #f8fbfa;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 7px;
  min-height: 118px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.metric-card.urgent {
  border-color: rgba(185, 92, 32, 0.32);
  background: #fffaf5;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  font-size: 18px;
}

.panel-header select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

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

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

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

th {
  background: #f8faf9;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: #f8fbfa;
}

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

.status-paid {
  background: rgba(21, 127, 59, 0.12);
  color: var(--success);
}

.status-partial {
  background: rgba(20, 116, 111, 0.12);
  color: var(--accent);
}

.status-unpaid {
  background: rgba(104, 115, 110, 0.12);
  color: #4d5954;
}

.status-overdue {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

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

.select-bill-button {
  min-width: 58px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.select-bill-button.selected {
  border-color: var(--accent);
  background: rgba(20, 116, 111, 0.12);
  color: var(--accent-strong);
}

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

.metric-action {
  padding: 0;
  font-size: 12px;
}

.text-button.align-left {
  justify-self: start;
}

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

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

.client-rank,
.client-grid,
.renewal-list,
.category-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.rank-item,
.client-card,
.category-item,
.renewal-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.rank-item {
  display: grid;
  gap: 8px;
}

.rank-line {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.rank-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.client-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.client-card {
  display: grid;
  gap: 12px;
}

.client-card h4 {
  margin: 0;
  font-size: 17px;
}

.client-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.client-total {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-weight: 800;
}

.client-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.store-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.store-summary span,
.store-summary small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
}

.store-summary strong {
  color: var(--ink);
}

.product-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
  gap: 18px;
}

.product-table {
  min-width: 980px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.partner-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.stacked-header {
  border-top: 1px solid var(--line);
}

.category-item,
.renewal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-item div,
.renewal-item div {
  display: grid;
  gap: 5px;
}

.category-item span,
.renewal-item span,
td small {
  color: var(--muted);
  font-size: 12px;
}

.renewal-panel {
  margin-top: 18px;
}

.renewal-item.expired {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff8f7;
}

.masked-value {
  color: var(--muted);
  font-weight: 800;
}

.annual-fields {
  display: none;
  gap: 14px;
  border: 1px solid rgba(20, 116, 111, 0.18);
  border-radius: 8px;
  background: rgba(20, 116, 111, 0.06);
  padding: 14px;
}

.annual-fields.active {
  display: grid;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

dialog.wide-dialog {
  width: min(980px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(10, 20, 18, 0.45);
}

.modal-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
}

.modal-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.store-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.store-edit-table {
  min-width: 780px;
}

.store-edit-table th,
.store-edit-table td {
  padding: 10px;
}

.store-edit-table input {
  min-width: 140px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 116, 111, 0.12);
  outline: none;
}

textarea {
  resize: vertical;
}

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

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

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .nav-list {
    grid-auto-flow: column;
  }

  .side-summary {
    margin-left: auto;
    margin-top: 0;
  }

  .metrics-grid,
  .content-grid,
  .product-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar,
  .topbar,
  .panel-header,
  .topbar-actions {
    align-items: stretch;
  }

  .sidebar,
  .topbar,
  .panel-header {
    flex-direction: column;
  }

  .nav-list {
    grid-auto-flow: row;
    width: 100%;
  }

  .side-summary {
    width: 100%;
    margin-left: 0;
  }

  .metrics-grid,
  .content-grid,
  .product-layout,
  .form-row {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .category-item,
  .renewal-item {
    grid-template-columns: 1fr;
  }

  .category-item,
  .renewal-item {
    align-items: stretch;
  }

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

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