:root {
  --bg: #f7f5ef;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --surface-dark: #35632a;
  --surface-dark-alt: #171c15;
  --line: rgba(53, 99, 42, 0.14);
  --text: #141512;
  --muted: #5b6357;
  --accent: #c71635;
  --accent-soft: rgba(199, 22, 53, 0.1);
  --danger: #af1632;
  --success: #4f8d1a;
  --brand-green: #3f7d2d;
  --brand-green-soft: #93c112;
  --brand-red: #c71635;
  --brand-ink: #111111;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-lg: 0 24px 70px rgba(24, 38, 19, 0.16);
  --shadow-md: 0 10px 30px rgba(24, 38, 19, 0.11);
  --font-sans: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  --font-display: "Georgia", "Iowan Old Style", serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 12% 10%, rgba(147, 193, 18, 0.24), transparent 22%),
    radial-gradient(circle at 86% 12%, rgba(199, 22, 53, 0.16), transparent 26%),
    radial-gradient(circle at 44% 82%, rgba(63, 125, 45, 0.12), transparent 24%),
    linear-gradient(145deg, #faf8f2 0%, #f4f1e7 48%, #ede9dc 100%);
  color: var(--text);
}

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

.hidden {
  display: none !important;
}

.ambient {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(24px);
  opacity: 0.34;
  pointer-events: none;
}

.ambient-a {
  width: 280px;
  height: 280px;
  top: 6%;
  left: 8%;
  background: rgba(147, 193, 18, 0.28);
}

.ambient-b {
  width: 340px;
  height: 340px;
  right: 6%;
  top: 18%;
  background: rgba(199, 22, 53, 0.18);
}

.ambient-c {
  width: 260px;
  height: 260px;
  left: 40%;
  bottom: 8%;
  background: rgba(63, 125, 45, 0.16);
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px;
}

.login-view {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  min-height: calc(100vh - 48px);
  align-items: stretch;
}

.login-copy,
.login-panel,
.sidebar,
.hero-card,
.panel-card,
.metric-card,
.drawer,
.modal-card {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-lg);
}

.login-copy,
.login-panel {
  border-radius: var(--radius-xl);
  padding: 40px;
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

.eyebrow,
.brand-overline,
.nav-group-label {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-copy h1,
.topbar h1,
.hero-card h2,
.drawer h2,
.modal-card h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 10px 0 14px;
  color: var(--surface-dark);
}

.login-copy h1 {
  font-size: clamp(2.3rem, 4vw, 4.2rem);
  line-height: 1.03;
}

.login-copy-text,
.hero-copy,
.sidebar-caption {
  color: var(--muted);
  line-height: 1.65;
}

.login-highlights,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.highlight-card,
.metric-card,
.info-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(244, 247, 238, 0.92));
  border: 1px solid rgba(53, 99, 42, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.highlight-card span,
.metric-card span,
.info-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.highlight-card strong,
.metric-card strong,
.info-card strong {
  font-size: 1.15rem;
  color: var(--surface-dark);
}

.brand-block,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 246, 236, 0.92));
  border: 1px solid rgba(53, 99, 42, 0.12);
  box-shadow: 0 10px 22px rgba(53, 99, 42, 0.12);
  overflow: hidden;
  padding: 5px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.panel-form,
.modal-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

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

.toggle-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.field span,
.toggle-field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field textarea,
.field select,
.lookup-input,
.line-table input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.lookup-input:focus,
.line-table input:focus {
  outline: none;
  border-color: rgba(63, 125, 45, 0.4);
  box-shadow: 0 0 0 4px rgba(147, 193, 18, 0.14);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
  font-weight: 600;
}

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

.button-primary {
  background: linear-gradient(125deg, var(--brand-green) 0%, var(--brand-green-soft) 46%, var(--brand-red) 100%);
  color: white;
  box-shadow: 0 14px 24px rgba(53, 99, 42, 0.18);
}

.button-secondary {
  background: rgba(63, 125, 45, 0.1);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(53, 99, 42, 0.08);
}

.button-ghost {
  background: transparent;
  color: var(--text);
}

.button-secondary:hover {
  background: rgba(63, 125, 45, 0.16);
}

.button-ghost:hover {
  background: rgba(199, 22, 53, 0.08);
}

.button-danger {
  background: rgba(199, 22, 53, 0.12);
  color: var(--danger);
}

.button-block {
  width: 100%;
}

.login-note,
.inline-badge,
.fixed-field,
.user-badge,
.sidebar-role {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(147, 193, 18, 0.16), rgba(199, 22, 53, 0.1));
  border: 1px solid rgba(53, 99, 42, 0.1);
  color: var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  min-height: calc(100vh - 48px);
}

.sidebar {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 85% 18%, rgba(199, 22, 53, 0.22), transparent 22%),
    linear-gradient(180deg, rgba(63, 125, 45, 0.98) 0%, rgba(53, 99, 42, 0.98) 42%, rgba(23, 28, 21, 0.98) 100%);
  color: #eff7f3;
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 60px rgba(17, 19, 16, 0.24);
}

.sidebar::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  top: -30px;
  right: -40px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(147, 193, 18, 0.18) 0%, rgba(147, 193, 18, 0) 68%);
  filter: blur(8px);
  z-index: -1;
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.sidebar .brand-overline,
.sidebar .nav-group-label,
.sidebar-caption,
.sidebar-role {
  color: rgba(239, 247, 243, 0.72);
}

.sidebar .sidebar-role {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(147, 193, 18, 0.18);
}

.sidebar-nav {
  display: grid;
  gap: 18px;
  margin-top: 32px;
}

.nav-group {
  display: grid;
  gap: 10px;
}

.nav-link {
  padding: 13px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(147, 193, 18, 0.18);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(147, 193, 18, 0.26), rgba(199, 22, 53, 0.16));
  border-color: rgba(255, 255, 255, 0.24);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

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

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

.topbar-actions,
.drawer-actions,
.toolbar-actions,
.pagination-actions,
.modal-actions,
.action-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  flex-direction: column;
  align-items: flex-start;
}

.user-badge span {
  color: var(--muted);
  font-size: 0.92rem;
}

.content,
.view-shell {
  display: grid;
  gap: 20px;
}

.hero-card,
.panel-card,
.metric-card {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.toolbar,
.toolbar-fields,
.form-grid,
.info-grid {
  display: grid;
  gap: 16px;
}

.toolbar {
  grid-template-columns: 1fr auto;
  margin-bottom: 16px;
}

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

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

.compact-field input {
  padding-block: 12px;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.32);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(63, 125, 45, 0.08);
}

.table-button {
  padding: 8px 12px;
}

.drawer {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(560px, calc(100vw - 48px));
  border-radius: var(--radius-xl);
  padding: 24px;
  z-index: 20;
  overflow: auto;
}

.drawer-body,
.modal-body,
.line-builder {
  display: grid;
  gap: 18px;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 25;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 16, 0.4);
}

.modal-card {
  position: relative;
  width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  border-radius: var(--radius-xl);
  padding: 24px;
  overflow: auto;
}

.lookup {
  position: relative;
}

.lookup-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 6px;
  z-index: 4;
}

.lookup-option {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 12px 14px;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.lookup-option:hover {
  background: rgba(244, 247, 238, 0.96);
  border-color: rgba(63, 125, 45, 0.18);
}

.line-label {
  min-width: 220px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.loading-card,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(63, 125, 45, 0.15);
  border-top-color: var(--brand-green);
  border-right-color: var(--brand-red);
  animation: spin 0.8s linear infinite;
}

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 12px;
  z-index: 40;
}

.toast {
  min-width: 260px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(17, 19, 16, 0.92);
  color: white;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 18px 32px rgba(17, 19, 16, 0.22);
}

.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background: rgba(63, 125, 45, 0.96);
}

.toast-error {
  background: rgba(175, 22, 50, 0.96);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .login-view,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .sidebar-nav,
  .toolbar,
  .toolbar-fields,
  .form-grid,
  .info-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

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

  .login-copy,
  .login-panel,
  .hero-card,
  .panel-card,
  .metric-card,
  .sidebar,
  .modal-card,
  .drawer {
    padding: 18px;
  }

  .drawer {
    top: 14px;
    right: 14px;
    left: 14px;
    width: auto;
    bottom: 14px;
  }

  .topbar,
  .drawer-header,
  .modal-header,
  .panel-header,
  .toolbar,
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .drawer-actions,
  .toolbar-actions,
  .pagination-actions,
  .modal-actions {
    flex-wrap: wrap;
  }
}
