:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --text: #1d2528;
  --muted: #65757c;
  --border: #d8e1e5;
  --accent: #0f7c72;
  --accent-2: #165d80;
  --danger: #b33a2f;
  --shadow: 0 10px 30px rgba(20, 40, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.4;
}

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

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

.login-card p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 24px;
}

.session-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

.topbar p,
.panel-title span,
.status,
.form-message,
.invoice-meta {
  color: var(--muted);
  font-size: 13px;
}

.status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.user-chip {
  background: #eef7f4;
  border: 1px solid #cde4dd;
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
}

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

.metric strong {
  color: var(--text);
  font-size: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(260px, 340px) minmax(420px, 1fr);
  gap: 16px;
  align-items: start;
}

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

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  margin-bottom: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 124, 114, 0.14);
}

textarea {
  resize: vertical;
}

.grid-two,
.grid-three,
.grid-four {
  display: grid;
  gap: 10px;
}

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

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

.grid-four {
  grid-template-columns: repeat(4, 1fr);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled {
  cursor: wait;
  opacity: 0.66;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.ghost {
  background: var(--surface-2);
  color: var(--accent-2);
}

.danger {
  background: #fff1ef;
  color: var(--danger);
  border: 1px solid #edc6c1;
}

.secondary {
  min-height: 72px;
  border-radius: 8px;
  border: 1px solid #bfd7df;
  background: #e8f3f2;
  color: var(--accent-2);
  padding: 0 18px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.button-icon {
  font-size: 16px;
  line-height: 1;
}

.form-message {
  min-height: 18px;
  margin-top: 10px;
}

.invoice-list {
  display: grid;
  gap: 8px;
  max-height: 72vh;
  overflow: auto;
  padding-right: 4px;
}

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

.admin-user-form {
  display: grid;
  gap: 4px;
}

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

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.disabled-row {
  opacity: 0.62;
}

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

.row-actions button,
.session-box button {
  min-height: 36px;
  padding: 0 12px;
}

.invoice-item {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
}

.invoice-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 124, 114, 0.12);
}

.invoice-item.duplicate {
  border-color: #d6a84a;
}

.invoice-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--accent-2);
  font-size: 12px;
  white-space: nowrap;
}

.warning-line {
  color: #8a5a00;
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 20px;
}

.empty-state.compact {
  min-height: 84px;
}

.hidden {
  display: none !important;
}

.review-content {
  display: grid;
  gap: 14px;
}

.preview {
  display: grid;
  min-height: 260px;
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
}

.preview iframe,
.preview img {
  width: 100%;
  border: 0;
  display: block;
}

.preview iframe {
  min-height: 440px;
}

.preview img {
  height: auto;
}

.preview-link {
  margin: auto;
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.raw-details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.raw-details summary {
  cursor: pointer;
  font-weight: 700;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  color: #36454c;
  font-size: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

@media (max-width: 1120px) {
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-link {
    grid-column: 1 / -1;
  }

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

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

  .review-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .session-box,
  .summary-strip,
  .workspace,
  .grid-two,
  .grid-three,
  .grid-four,
  .actions {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .session-box {
    display: grid;
    justify-content: stretch;
  }

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

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