:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #687383;
  --quiet: #9aa4b2;
  --line: #e8ebf1;
  --panel: #ffffff;
  --bg: #fbfbfd;
  --navy: #070735;
  --navy-2: #0d0d4f;
  --blue: #2337ff;
  --blue-soft: #eef1ff;
  --purple: #8d5cff;
  --green: #10a66a;
  --green-soft: #eaf8f1;
  --amber: #b87508;
  --red: #ba4545;
  --shadow: 0 28px 90px rgba(12, 18, 36, .12);
  --soft-shadow: 0 14px 38px rgba(12, 18, 36, .08);
  --radius: 28px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 0%, rgba(141, 92, 255, .11), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(35, 55, 255, .10), transparent 30%),
    linear-gradient(180deg, #fff 0%, #f8f8fd 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

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

.auth-card {
  width: min(520px, 100%);
  padding: 34px;
  border-radius: 32px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(141, 92, 255, .46), transparent 34%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
  box-shadow: 0 30px 90px rgba(7, 7, 53, .28);
}

.auth-brand {
  padding-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  min-height: 52px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 10px 14px;
  color: #fff;
  background: rgba(255,255,255,.10);
}

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

.sidebar {
  margin: 18px 0 18px 18px;
  padding: 24px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(141, 92, 255, .42), transparent 28%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 30px 90px rgba(7, 7, 53, .28);
}

.brand {
  padding: 8px 4px 18px;
}

.brand img {
  display: block;
  width: min(230px, 100%);
  height: auto;
  object-fit: contain;
}

.auth-brand img {
  width: min(310px, 100%);
}

.brand strong {
  display: block;
  font-size: 28px;
  line-height: 1.03;
  letter-spacing: 0;
}

.brand span {
  color: rgba(255,255,255,.68);
  font-size: 13px;
}

.user-card, .empty-state {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 12px;
  background: rgba(255,255,255,.08);
}

.user-card span {
  display: block;
  color: rgba(255,255,255,.58);
  font-size: 12px;
  font-weight: 800;
}

.user-card strong {
  display: block;
  margin: 4px 0 10px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.empty-state {
  color: rgba(255,255,255,.72);
  font-size: 13px;
  line-height: 1.4;
}

.small, .client-meta {
  color: var(--muted);
  font-size: 13px;
}

.sidebar h3 {
  color: rgba(255,255,255,.56);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
}

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

.mini-button {
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
}

.client-list, .client-settings, .rules, .detail, .edit-form, .user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: stretch;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 22px;
  padding: 8px;
}

.client-card.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(0,0,0,.18);
}

.client-main {
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px;
  cursor: pointer;
}

.client-main strong {
  display: block;
  font-size: 17px;
  margin-bottom: 5px;
}

.client-main span {
  display: block;
  color: rgba(255,255,255,.62);
  font-size: 13px;
  line-height: 1.35;
}

.client-card.active .client-main span {
  color: var(--muted);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 16px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.74);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0;
}

.client-card.active .icon-button {
  background: var(--blue-soft);
  color: var(--blue);
}

.client-form, .client-settings.open, .admin-box.open {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  padding: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
}

.admin-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-settings { display: none; }
.client-settings.open { display: flex; }

.client-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.client-form label, .dark-field, .edit-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: rgba(255,255,255,.68);
  font-size: 12px;
}

.edit-form label {
  color: var(--muted);
}

.client-form input, .client-form select, .dark-field input, .dark-field select {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  min-height: 42px;
  padding: 8px 11px;
  color: #fff;
  background: rgba(255,255,255,.10);
}

.client-form select option, .dark-field select option {
  color: var(--ink);
  background: #fff;
}

.client-form input::placeholder, .dark-field input::placeholder { color: rgba(255,255,255,.42); }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: rgba(255,255,255,.68);
  font-size: 12px;
}

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

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

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

.choice-card {
  position: relative;
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 17px;
  padding: 10px 12px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  font-weight: 850;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.choice-card.compact {
  min-height: 40px;
  padding-inline: 8px;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card:has(input:checked) {
  color: var(--ink);
  background: #fff;
  border-color: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}

.choice-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.30);
}

.form-grid, .edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.form-checks, .firm-access-list {
  display: grid;
  gap: 7px;
}

.form-checks label, .inline-check {
  flex-direction: row;
  align-items: center;
  color: rgba(255,255,255,.82);
}

.form-checks.modern {
  grid-template-columns: 1fr;
}

.form-checks.modern label {
  min-height: 42px;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255,255,255,.07);
  font-size: 13px;
  font-weight: 800;
}

.form-checks.modern input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.firm-access-list {
  max-height: 150px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.06);
}

.firm-access-list.tall {
  max-height: 210px;
}

.user-row {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 11px;
  background: rgba(255,255,255,.07);
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.user-row:hover,
.user-row.selected {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.32);
  background: rgba(255,255,255,.12);
}

.user-row strong,
.user-row span,
.user-row em,
.user-row small {
  display: block;
}

.user-row strong {
  font-size: 14px;
}

.user-row span {
  margin-top: 3px;
  color: rgba(255,255,255,.64);
  font-size: 12px;
}

.user-row em {
  margin-top: 6px;
  color: rgba(255,255,255,.48);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.user-row small {
  margin-top: 6px;
  color: rgba(255,255,255,.72);
  font-size: 11px;
  font-weight: 800;
}

.user-detail-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  padding: 14px;
  background: rgba(10, 8, 43, .30);
}

.user-detail-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: rgba(255,255,255,.68);
  font-size: 12px;
}

.user-detail-card input,
.user-detail-card select {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  min-height: 42px;
  padding: 8px 11px;
  color: #fff;
  background: rgba(255,255,255,.10);
}

.user-detail-card select option {
  color: var(--ink);
  background: #fff;
}

.user-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-detail-head strong,
.user-detail-head span {
  display: block;
}

.user-detail-head strong {
  font-size: 16px;
}

.user-detail-head span {
  margin-top: 3px;
  color: rgba(255,255,255,.62);
  font-size: 12px;
}

.user-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.user-stats div {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 17px;
  padding: 10px;
  background: rgba(255,255,255,.08);
}

.user-stats span,
.user-stats strong {
  display: block;
}

.user-stats span {
  color: rgba(255,255,255,.56);
  font-size: 11px;
}

.user-stats strong {
  margin-top: 4px;
  font-size: 18px;
}

.main {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 22px;
  color: #fff;
  background:
    radial-gradient(circle at 74% 16%, rgba(141, 92, 255, .42), transparent 24%),
    linear-gradient(135deg, var(--navy), var(--navy-2));
  border-radius: 34px;
  padding: 30px;
  box-shadow: var(--shadow);
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: 36px;
  line-height: 1.06;
  letter-spacing: 0;
}

h2 { font-size: 20px; }
h3 { font-size: 15px; }

.topbar .small {
  color: rgba(255,255,255,.66);
}

.period-pill {
  display: inline-flex;
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  color: rgba(255,255,255,.65);
  font-size: 12px;
}

select, input[type="file"], .edit-form input, .edit-form select {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 44px;
  border-radius: 18px;
  padding: 8px 13px;
  color: var(--ink);
}

.month-control {
  display: grid;
  grid-template-columns: 44px minmax(160px, auto) 44px;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.11);
  overflow: hidden;
}

.month-control strong {
  color: #fff;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}

.month-control button {
  height: 48px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.82);
  cursor: pointer;
  font-size: 24px;
  font-weight: 800;
}

.month-control button:hover {
  background: rgba(255,255,255,.10);
  color: #fff;
}

.button {
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 850;
  box-shadow: 0 18px 36px rgba(35, 55, 255, .22);
}

.button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}

.button.success {
  background: linear-gradient(135deg, var(--blue), var(--purple));
}

.button.download {
  background: #fff;
  color: var(--blue);
  box-shadow: none;
}

.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.notice {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  color: #fff;
  font-size: 13px;
}

.admin-notice {
  max-width: none;
  min-height: auto;
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 20px;
  background: rgba(255, 255, 255, .09);
  color: rgba(255, 255, 255, .9);
  font-weight: 800;
}

.download-line {
  grid-column: 1 / -1;
  color: rgba(255,255,255,.66);
  font-size: 12px;
}

.download-line code {
  color: #fff;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  padding: 5px 8px;
  word-break: break-all;
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-top: -8px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid rgba(232,235,241,.92);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.metric {
  padding: 20px;
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 6px;
}

.storage-metric strong {
  font-size: 20px;
}

.storage-metric em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.panel {
  padding: 20px;
}

.panel-head, .detail-head, .settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-head { margin-bottom: 16px; }

.dropzone {
  border: 1px solid #e7eaf2;
  border-radius: 28px;
  padding: 20px;
  background:
    radial-gradient(circle at 82% 20%, rgba(35, 55, 255, .08), transparent 26%),
    #fbfbfe;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr);
  align-items: center;
  gap: 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
}

.drop-copy strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.upload-actions {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) minmax(180px, 260px);
  gap: 10px;
  align-items: center;
}

.file-native {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--blue);
  background: #fff;
  border: 1px solid #dfe4ef;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(12, 18, 36, .06);
}

.file-summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid #e2e6ef;
  background: #fff;
  color: var(--muted);
  border-radius: 18px;
  padding: 9px 13px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status.ready { background: var(--green-soft); color: var(--green); }
.status.review { background: #fff4d8; color: #b87508; }
.status.error { background: #ffe8e5; color: #ba4545; }

.export-state {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.export-state.done {
  background: #e8f8f0;
  color: #117847;
}

.export-state.waiting {
  background: #edf0f8;
  color: #667085;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
}

.table-wrap {
  overflow: auto;
  border-radius: 24px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  background: transparent;
  min-width: 920px;
}

th, td {
  text-align: left;
  padding: 15px 16px;
  vertical-align: top;
  font-size: 14px;
}

th {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

tbody tr {
  background: #fff;
  box-shadow: 0 10px 26px rgba(12, 18, 36, .05);
}

tbody td {
  border-top: 1px solid #eef1f6;
  border-bottom: 1px solid #eef1f6;
}

tbody td:first-child {
  border-left: 1px solid #eef1f6;
  border-radius: 18px 0 0 18px;
}

tbody td:last-child {
  border-right: 1px solid #eef1f6;
  border-radius: 0 18px 18px 0;
}

tbody tr:hover td { background: #fafbff; }
tr.selected td { background: #f0f3ff; border-color: #d9e2ff; }
tr[data-doc-row] { cursor: pointer; }

.row-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-weight: 900;
}

.kv {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 8px;
  font-size: 14px;
}

.kv span { color: var(--muted); }

.warning-list {
  margin: 0;
  padding-left: 18px;
  color: var(--amber);
  font-size: 14px;
}

.line-items, .line-editor {
  display: grid;
  gap: 8px;
}

.line-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid #edf0f7;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fafbff);
}

.line-item strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.line-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.line-item b {
  white-space: nowrap;
  color: var(--blue);
}

.line-editor-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 90px;
  gap: 10px;
  padding: 12px;
  border: 1px solid #edf0f7;
  border-radius: 18px;
  background: #fafbff;
}

.detail-actions {
  display: flex;
  justify-content: flex-start;
}

.detail-actions .button {
  width: 100%;
  box-shadow: 0 16px 30px rgba(35, 55, 255, .16);
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px;
  color: #26313a;
  background: #fbfbfd;
}

.ocr-preview {
  border: 1px solid #e8ebf4;
  border-radius: 18px;
  background: #fbfcff;
  overflow: hidden;
}

.ocr-preview summary {
  min-height: 48px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 850;
  color: var(--ink);
}

.ocr-preview summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ocr-preview pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid #e8ebf4;
  padding: 14px;
  color: #334155;
  background: #fff;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.saved-note {
  color: rgba(255,255,255,.52);
  font-size: 12px;
}

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

.toggle {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 18px;
  padding: 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.toggle strong {
  min-width: 38px;
  text-align: center;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.72);
  padding: 2px 8px;
}

.toggle.on {
  border-color: rgba(141, 92, 255, .58);
  background: rgba(141, 92, 255, .22);
}

.toggle.on strong {
  background: #fff;
  color: var(--navy);
}

.rule {
  border-left: 4px solid var(--purple);
  padding: 9px 11px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.82);
  font-size: 13px;
  border-radius: 0 16px 16px 0;
}

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { margin: 16px; }
  .layout, .grid, .topbar { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-start; }
  .dropzone, .upload-actions { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .main, .sidebar { padding: 16px; }
  .grid, .layout { grid-template-columns: 1fr; }
  .dropzone { flex-direction: column; align-items: stretch; }
  .line-editor-row { grid-template-columns: 1fr; }
}
