:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1f2b;
  --muted: #647084;
  --line: #d8dee8;
  --green: #087f5b;
  --green-dark: #065f46;
  --amber: #a15c07;
  --red: #b42318;
  --blue: #2764a9;
  --shadow: 0 18px 55px rgba(34, 44, 63, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.control-panel {
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  padding: 26px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

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

h1,
h2,
p {
  margin: 0;
}

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

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.form {
  display: grid;
  gap: 15px;
}

.settings-panel,
.memory-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.settings-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  margin-bottom: 20px;
  scroll-margin-top: 18px;
}

.settings-panel h2,
.memory-panel h2 {
  margin-bottom: 14px;
  font-size: 16px;
}

.settings-form,
.memory-form {
  display: grid;
  gap: 12px;
}

.csv-settings-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

.usage-panel h2 {
  margin-bottom: 12px;
}

.usage-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

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

.usage-card {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.usage-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.usage-card strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.usage-client-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.usage-client-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  font-size: 12px;
}

.usage-client-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-client-row span {
  color: var(--muted);
  white-space: nowrap;
}

.settings-action,
.memory-action {
  width: 100%;
}

.toggle-grid {
  display: grid;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
}

.preference-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

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

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

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.12);
}

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

.drop-zone {
  min-height: 104px;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed #9aa7b8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  padding: 18px;
}

.drop-zone.dragging {
  border-color: var(--green);
  background: #eefaf5;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone small {
  color: var(--muted);
  font-weight: 600;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: #fff;
}

.primary-action:hover {
  background: var(--green-dark);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-action {
  min-width: 88px;
  padding: 0 18px;
  background: #eef2f7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-action:not(:disabled):hover {
  border-color: var(--blue);
  color: var(--blue);
}

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

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.link-action {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.is-disabled-link {
  pointer-events: none;
  opacity: 0.55;
}

.workspace-header h2 {
  font-size: 30px;
  line-height: 1.15;
}

.status-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 56px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-panel span {
  color: var(--muted);
  text-align: right;
}

.status-panel.ok {
  border-left-color: var(--green);
}

.status-panel.error {
  border-left-color: var(--red);
}

.status-panel.working {
  border-left-color: var(--amber);
}

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

.summary-item {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 9px;
  text-transform: uppercase;
}

.summary-item strong {
  font-size: 18px;
}

.warnings {
  margin-bottom: 16px;
  border: 1px solid rgba(180, 35, 24, 0.25);
  border-radius: 8px;
  background: #fff7f5;
  color: #7a271a;
  padding: 12px 14px;
}

.history-panel {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.history-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-panel h2 {
  font-size: 16px;
}

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

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.history-details > div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}

.history-details > div:first-child {
  grid-template-columns: 1fr auto;
}

.history-details strong {
  margin: 0;
}

.history-details small {
  color: var(--muted);
  white-space: nowrap;
}

.history-details span {
  display: inline;
  color: var(--muted);
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}


.history-item:first-child {
  border-top: 0;
}

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

.history-item small,
.history-list p {
  color: var(--muted);
}

.warnings ul {
  margin: 0;
  padding-left: 18px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f0f3f7;
  color: #384256;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.amount {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 38px;
}

.review {
  color: var(--amber);
  font-weight: 800;
}

.valid {
  color: var(--green);
  font-weight: 800;
}

.auth-page {
  background:
    radial-gradient(circle at top left, rgba(8, 127, 91, 0.12), transparent 34%),
    linear-gradient(180deg, #f7faf8 0%, #eef3f8 100%);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(280px, 1fr);
  gap: 24px;
  align-items: center;
  padding: 32px;
}

.auth-card,
.auth-side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 32px;
}

.auth-side-panel {
  padding: 28px;
}

.auth-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.auth-card h1,
.auth-side-panel h2 {
  margin-bottom: 12px;
  line-height: 1.1;
}

.auth-card h1 {
  font-size: 34px;
}

.auth-side-panel h2 {
  font-size: 26px;
}

.auth-copy {
  color: var(--muted);
  line-height: 1.6;
}

.auth-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.auth-main-action,
.auth-secondary-action {
  width: 100%;
}

.auth-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.auth-side {
  display: flex;
  justify-content: stretch;
}

.settings-page {
  background:
    radial-gradient(circle at top left, rgba(39, 100, 169, 0.12), transparent 36%),
    linear-gradient(180deg, #f8fbfd 0%, #eef3f8 100%);
}

.settings-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.settings-card-page {
  width: min(100%, 920px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  padding: 30px;
}

.settings-page-head {
  margin-bottom: 20px;
}

.settings-page-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.settings-card-page h1 {
  font-size: 30px;
  line-height: 1.12;
}

.settings-session-note {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

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

.settings-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.settings-block h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

.settings-page-form {
  gap: 14px;
}

.settings-usage-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 22px 16px;
  }

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

  .auth-shell {
    grid-template-columns: 1fr;
    padding: 20px;
  }
}

@media (max-width: 560px) {
  .control-panel {
    padding: 18px;
  }

  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: stretch;
    width: 100%;
  }

  .secondary-action {
    width: 100%;
  }

  .status-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-panel span {
    text-align: left;
  }

  .settings-card-page {
    padding: 22px 18px;
  }

  .settings-page-actions {
    display: grid;
  }
}
