:root {
  --bg: #f4efe8;
  --surface: rgba(255, 252, 246, 0.88);
  --surface-strong: #fffaf2;
  --surface-dark: #1e1510;
  --line: rgba(104, 79, 55, 0.14);
  --text: #241913;
  --muted: #6b5847;
  --primary: #c25c32;
  --primary-dark: #8b3f21;
  --teal: #145b55;
  --teal-soft: rgba(20, 91, 85, 0.12);
  --gold: #d7b16d;
  --danger: #b23a33;
  --shadow: 0 24px 80px rgba(54, 31, 17, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(194, 92, 50, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(20, 91, 85, 0.16), transparent 35%),
    linear-gradient(140deg, #f8f3ea 0%, #efe4d5 45%, #f6f1ea 100%);
}

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

.ambient {
  position: fixed;
  z-index: 0;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.18;
  pointer-events: none;
}

.ambient-one {
  top: -8rem;
  left: -10rem;
  background: #d3774d;
}

.ambient-two {
  bottom: -10rem;
  right: -10rem;
  background: #1e7b6c;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--teal);
}

.shell-header,
.app-shell,
.auth-modal {
  position: relative;
  z-index: 1;
}

.shell-header {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.shell-header h1,
.hero h2,
.section-heading h3,
.invoice-header h2,
.auth-copy h2,
.sidebar h2 {
  margin: 0;
  line-height: 1.05;
}

.brand-block h1 {
  font-size: clamp(2.6rem, 4vw, 4rem);
}

.brand-copy {
  max-width: 56ch;
  line-height: 1.7;
  color: var(--muted);
  margin: 12px 0 0;
}

.header-actions,
.hero-actions,
.button-row,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

.panel,
.auth-card {
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(30, 21, 16, 0.97), rgba(51, 34, 24, 0.96));
  color: #f6ede0;
}

.sidebar .eyebrow {
  color: #dfbe93;
}

.sidebar-top h2 {
  font-size: 2rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff5e6;
  margin-top: 12px;
}

.pill-admin {
  background: rgba(215, 177, 109, 0.18);
  color: #6f4d14;
}

.sidebar-card,
.metric-card {
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-card {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card span,
.metric-card span {
  display: block;
  font-size: 0.85rem;
  color: rgba(246, 237, 224, 0.7);
}

.sidebar-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2.1rem;
}

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

.metric-card {
  background: rgba(255, 255, 255, 0.05);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: #fff6ec;
}

.sidebar-note p:last-child {
  margin: 8px 0 0;
  line-height: 1.6;
  color: rgba(246, 237, 224, 0.76);
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.hero h2 {
  font-size: clamp(2rem, 3vw, 3rem);
  max-width: 24ch;
}

.hero-copy {
  max-width: 62ch;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 12px;
}

.status-message {
  min-height: 1.2rem;
  margin: 0 2px;
  color: var(--teal);
}

.status-message.error {
  color: var(--danger);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(380px, 0.88fr);
  gap: 22px;
}

.form-column,
.preview-column {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.field-grid,
.charges-grid,
.mini-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-span-2 {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 30px;
}

.checkbox-label input {
  width: auto;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(109, 87, 63, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(194, 92, 50, 0.55);
  box-shadow: 0 0 0 4px rgba(194, 92, 50, 0.12);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
}

button {
  border: none;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.primary-btn,
.secondary-btn,
.ghost-btn,
.close-btn {
  border-radius: 999px;
  padding: 12px 18px;
}

.compact-btn {
  padding: 9px 14px;
}

.primary-btn {
  background: var(--primary);
  color: #fff8f3;
}

.secondary-btn {
  background: var(--teal-soft);
  color: var(--teal);
}

.ghost-btn {
  background: rgba(36, 25, 19, 0.08);
  color: var(--text);
}

.items-table-wrap {
  overflow-x: auto;
}

.items-table,
.preview-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th,
.items-table td,
.preview-table th,
.preview-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}

.items-table th,
.preview-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.item-total-cell {
  font-weight: 700;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(194, 92, 50, 0.12);
  color: var(--primary-dark);
}

.invoice-preview {
  padding: 28px;
  border-radius: 26px;
  background: var(--surface-strong);
  border: 1px solid rgba(104, 79, 55, 0.12);
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.invoice-tag,
.preview-title {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--primary);
}

.invoice-meta p,
.totals-panel p,
.mini-grid p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 10px;
}

.invoice-meta span,
.totals-panel span,
.mini-grid span {
  color: var(--muted);
}

.preview-block {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.preview-block:last-child {
  border-bottom: none;
}

.totals-panel {
  padding-top: 20px;
}

.grand-total {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed rgba(104, 79, 55, 0.32);
  font-size: 1.08rem;
}

.history-list,
.users-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.history-item,
.user-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(20, 91, 85, 0.08);
}

.history-item h4,
.history-item p,
.user-card h4,
.user-card p {
  margin: 0;
}

.history-item h4,
.user-card h4 {
  margin-bottom: 6px;
}

.history-item p,
.user-card p,
.user-hint {
  color: var(--muted);
  line-height: 1.45;
}

.admin-grid {
  margin-top: 6px;
}

.admin-form {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(104, 79, 55, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-form h4 {
  margin: 0 0 6px;
}

.admin-users-heading {
  margin-top: 18px;
}

.user-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 11, 8, 0.55);
}

.auth-card {
  position: relative;
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.auth-copy {
  padding: 42px;
  background:
    radial-gradient(circle at top left, rgba(215, 177, 109, 0.18), transparent 35%),
    linear-gradient(150deg, rgba(30, 21, 16, 0.98), rgba(61, 38, 27, 0.95));
  color: #f6ede0;
}

.auth-copy p {
  line-height: 1.7;
  color: rgba(246, 237, 224, 0.78);
}

.auth-form {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.auth-panel {
  display: flex;
  flex-direction: column;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  padding: 24px 24px 0;
  flex-wrap: wrap;
}

.auth-tab {
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(36, 25, 19, 0.08);
  color: var(--text);
}

.auth-tab.active {
  background: var(--primary);
  color: #fff8f3;
}

.auth-link-btn {
  align-self: flex-start;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.error-text {
  min-height: 1.2rem;
  margin: 0;
  color: var(--danger);
}

.empty-state,
.history-empty {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 1240px) {
  .app-shell,
  .workspace-grid,
  .auth-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell-header,
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .shell-header,
  .hero,
  .section-heading,
  .invoice-header,
  .user-card-top {
    flex-direction: column;
    align-items: stretch;
  }

  .field-grid,
  .charges-grid,
  .mini-grid,
  .admin-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .panel,
  .invoice-preview,
  .auth-copy,
  .auth-form {
    padding: 20px;
  }

  .auth-tabs {
    padding: 20px 20px 0;
  }
}

@media print {
  body {
    background: #fff;
  }

  .ambient,
  .shell-header,
  .hero,
  #premiumPanel,
  #adminPanel,
  .form-column,
  .status-message {
    display: none !important;
  }

  .app-shell,
  .main-column,
  .workspace-grid,
  .preview-column,
  .panel,
  .invoice-preview {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    background: #fff;
    box-shadow: none;
    border: none;
  }

  .sidebar {
    display: none;
  }
}
