* { box-sizing: border-box; }

:root {
  --bg: #f5efe6;
  --bg-accent: #eadfce;
  --surface: rgba(255, 252, 247, 0.88);
  --surface-strong: #fffdf9;
  --surface-dark: #123629;
  --line: rgba(73, 52, 32, 0.12);
  --text: #1f2937;
  --text-soft: #6b7280;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --danger: #c2410c;
  --shadow: 0 24px 60px rgba(50, 39, 24, 0.12);
  --radius: 22px;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(194, 65, 12, 0.14), transparent 28%),
    linear-gradient(135deg, var(--bg) 0%, #f8f3eb 40%, var(--bg-accent) 100%);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

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

.login-layout {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 420px);
  gap: 24px;
  align-items: stretch;
}

.login-intro {
  background: linear-gradient(160deg, rgba(18, 54, 41, 0.94), rgba(15, 118, 110, 0.82));
  color: #f8fafc;
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 20px;
  height: auto;
}

.login-intro h1 {
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin: 14px 0 18px;
  max-width: 10ch;
}

.lead {
  font-size: 17px;
  line-height: 1.6;
  color: rgba(248, 250, 252, 0.82);
  max-width: 52ch;
}

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

.highlight-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.highlight-card strong {
  display: block;
  font-size: 28px;
  margin-bottom: 4px;
}

.highlight-card span {
  color: rgba(248, 250, 252, 0.76);
  font-size: 14px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  height: 400px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 30px;
  margin-bottom: 6px;
}

h3 {
  font-size: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
}

.login-intro .eyebrow,
.sidebar .eyebrow {
  color: rgba(255, 255, 255, 0.74);
}

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

.section-head.compact {
  display: block;
  margin-bottom: 20px;
}

.section-head p {
  margin: 0;
  max-width: 44ch;
}

.section-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.field-help {
  margin: 6px 0 0;
}

input, select, button, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.88);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  background: #fff;
  font-weight: 700;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

.btn-danger {
  background: linear-gradient(135deg, #ea580c, var(--danger));
  color: #fff;
  border-color: transparent;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
  font-weight: 700;
}

.btn-small {
  width: auto;
  min-width: 84px;
  padding: 8px 12px;
  font-size: 12px;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash.info {
  background: #e8f1fe;
  color: #1e3a8a;
  border-color: #bfdbfe;
}

.flash.error {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

.flash.success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  gap: 20px;
  padding: 20px;
}

.sidebar {
  background: linear-gradient(180deg, rgba(18, 54, 41, 0.94), rgba(13, 148, 136, 0.84));
  color: #f8fafc;
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.brand-block {
  margin-bottom: 24px;
}

.brand-block h2 {
  color: #fff;
  margin: 8px 0 10px;
}

.brand-block .muted,
.topbar-copy .muted {
  color: rgba(226, 232, 240, 0.78);
}

.menu a {
  display: block;
  text-decoration: none;
  color: rgba(248, 250, 252, 0.9);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.menu a.active {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(255, 255, 255, 0.94);
  color: var(--surface-dark);
  box-shadow: 0 14px 30px rgba(7, 15, 13, 0.18);
}

.menu a:hover {
  transform: translateX(2px);
  border-color: rgba(255, 255, 255, 0.24);
}

.main {
  padding: 0;
}

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

.topbar .logout {
  width: auto;
  min-width: 110px;
}

.topbar-copy strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.section {
  margin-bottom: 18px;
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(73, 52, 32, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

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

th, td {
  border-bottom: 1px solid rgba(73, 52, 32, 0.08);
  text-align: left;
  padding: 12px 12px;
  font-size: 13px;
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.72);
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.05);
}

.muted {
  color: var(--text-soft);
  font-size: 13px;
}

.inline {
  display: inline;
}

.inline button {
  width: auto;
}

.actions-cell {
  white-space: nowrap;
}

.divider {
  position: relative;
  margin: 24px 0 18px;
  text-align: center;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(73, 52, 32, 0.12);
}

.divider span {
  position: relative;
  display: inline-block;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.db-meta {
  margin: 18px 0 0;
}

.is-hidden {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.46);
  backdrop-filter: blur(5px);
  z-index: 50;
}

.modal-shell.is-open {
  display: flex;
}

.modal-shell-wide .modal-card {
  max-width: 900px;
}

.modal-card {
  width: min(100%, 620px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface-strong);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  padding: 22px;
}

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

.modal-form {
  margin: 0;
}

.modal-actions {
  margin-bottom: 0;
}

.icon-btn {
  width: auto;
  min-width: 44px;
  padding: 10px 14px;
  font-size: 20px;
  line-height: 1;
}

a {
  color: var(--primary-strong);
}

@media (max-width: 900px) {
  .login-layout,
  .app {
    grid-template-columns: 1fr;
  }

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

  .section-head {
    display: block;
  }

  .section-toolbar,
  .form-grid,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .section-toolbar {
    display: grid;
  }

  .login-intro {
    min-height: auto;
  }

  .login-card {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .card,
  .sidebar,
  .login-intro,
  .modal-card {
    padding: 18px;
    border-radius: 22px;
  }

  .app {
    padding: 12px;
    gap: 12px;
  }

  .login-wrap,
  .modal-shell {
    padding: 14px;
  }

  .login-highlights {
    grid-template-columns: 1fr;
  }

  .login-intro h1 {
    font-size: 34px;
  }

  .actions-cell {
    white-space: normal;
  }
}
