@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  --ink: #14221f;
  --muted: #63736f;
  --green-950: #072a23;
  --green-900: #0b3b31;
  --green-800: #105144;
  --green-100: #e9f2ef;
  --green-50: #f3f8f6;
  --gold: #d7a64a;
  --gold-soft: #f6ead0;
  --line: #dfe7e4;
  --surface: #ffffff;
  --canvas: #f6f8f7;
  --danger: #b53e45;
  --danger-soft: #fcebec;
  --shadow: 0 24px 60px rgba(7, 42, 35, .12);
  --shadow-sm: 0 8px 24px rgba(7, 42, 35, .07);
  --radius: 20px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

img, svg { max-width: 100%; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  position: relative;
  z-index: 10;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid rgba(11, 59, 49, .09);
}

.header-inner {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand img { display: block; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-family: "Manrope", sans-serif; font-size: 1rem; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .73rem; }

.main-nav { display: flex; align-items: center; gap: 8px; }

.nav-link {
  padding: 10px 14px;
  color: #53635f;
  border: 0;
  border-radius: 9px;
  background: none;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
}

.nav-link:hover, .nav-link.active { color: var(--green-900); background: var(--green-50); }
.nav-admin { color: var(--green-900); }

.hero {
  position: relative;
  min-height: calc(100vh - 142px);
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 20%, rgba(215, 166, 74, .13), transparent 28%),
    radial-gradient(circle at 96% 85%, rgba(36, 113, 95, .11), transparent 30%),
    linear-gradient(135deg, #f9faf9 0%, #eff5f2 100%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: linear-gradient(rgba(11,59,49,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(11,59,49,.12) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(90deg, black, transparent 45%);
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: .82fr 1.18fr;
  align-items: center;
  gap: clamp(48px, 8vw, 110px);
  padding-block: clamp(54px, 8vh, 90px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green-800);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2aa776;
  box-shadow: 0 0 0 5px rgba(42, 167, 118, .12);
}

.hero-copy h1, .dashboard-heading h1 {
  margin: 22px 0 20px;
  font: 800 clamp(2.7rem, 5.2vw, 5.3rem)/.98 "Manrope", sans-serif;
  letter-spacing: -.065em;
  color: var(--green-950);
}

.hero-copy h1 span { color: var(--green-800); }
.hero-copy > p { max-width: 520px; margin: 0; color: var(--muted); font-size: 1.05rem; }

.trust-list {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 32px;
  color: #4e5e5a;
  font-size: .82rem;
  font-weight: 600;
}

.trust-list span { display: inline-flex; align-items: center; gap: 7px; }
.trust-list i { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; color: var(--green-800); background: #dcece6; font-style: normal; font-size: .7rem; }

.form-card {
  padding: clamp(26px, 4vw, 44px);
  border: 1px solid rgba(11, 59, 49, .08);
  border-radius: 26px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow);
}

.card-heading, .panel-heading, .dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.step-label { color: var(--gold); font-size: .71rem; font-weight: 800; letter-spacing: .13em; }
.card-heading h2, .panel-heading h2, .dialog-heading h2 { margin: 5px 0 0; font: 700 1.5rem/1.25 "Manrope", sans-serif; letter-spacing: -.035em; }

.record-count {
  flex: 0 0 auto;
  padding: 6px 10px;
  color: var(--green-800);
  border-radius: 999px;
  background: var(--green-100);
  font-size: .72rem;
  font-weight: 700;
}

.form-card form { margin-top: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; }
.field-group { min-width: 0; }

.field-group label {
  display: block;
  margin-bottom: 8px;
  font-size: .82rem;
  font-weight: 700;
}

.field-group label span { color: var(--gold); }

input, select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid #d9e2df;
  border-radius: 10px;
  outline: none;
  background: #fbfcfc;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

input::placeholder { color: #9aa7a3; }
input:focus, select:focus { border-color: var(--green-800); background: #fff; box-shadow: 0 0 0 4px rgba(16, 81, 68, .09); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(181, 62, 69, .08); }

.field-error {
  display: block;
  min-height: 18px;
  margin-top: 5px;
  color: var(--danger);
  font-size: .72rem;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 22px;
  color: #53635f;
  font-size: .78rem;
  cursor: pointer;
}

.consent-row input { flex: 0 0 auto; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--green-800); }
.consent-error { margin: 2px 0 0 27px; }

.primary-button, .secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: .86rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}

.primary-button { width: 100%; margin-top: 7px; color: #fff; background: var(--green-900); box-shadow: 0 9px 20px rgba(11, 59, 49, .17); }
.primary-button:hover { background: var(--green-800); transform: translateY(-1px); box-shadow: 0 12px 24px rgba(11, 59, 49, .22); }
.primary-button:active, .secondary-button:active { transform: translateY(0); }
.primary-button.compact { width: auto; min-height: 44px; margin: 0; }
.button-icon { margin-left: auto; font-size: 1.1rem; }

.storage-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 22px 0 0;
  padding-top: 18px;
  color: #7c8986;
  border-top: 1px solid #edf1f0;
  font-size: .71rem;
}
.storage-note span { color: var(--gold); font-size: .55rem; line-height: 2.1; }

.site-footer { color: #75817e; background: #fff; border-top: 1px solid var(--line); font-size: .76rem; }
.footer-inner { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  min-width: min(370px, calc(100vw - 48px));
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 18px;
  color: #fff;
  border-radius: 13px;
  background: var(--green-950);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--green-950); background: #bce8d3; font-weight: 900; }
.toast div { display: flex; flex-direction: column; }
.toast strong { font-size: .85rem; }
.toast small { color: rgba(255, 255, 255, .7); font-size: .72rem; }

/* Admin */
.admin-body { background: #f3f6f5; }
.admin-main { min-height: calc(100vh - 82px); }
.login-section { min-height: calc(100vh - 82px); display: grid; place-items: center; padding: 50px 20px; background: radial-gradient(circle at 50% 8%, rgba(215,166,74,.14), transparent 31%), linear-gradient(145deg, #edf4f1, #f9faf9); }
.login-card { width: min(440px, 100%); padding: 42px; text-align: center; border: 1px solid rgba(11,59,49,.1); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.lock-mark { width: 58px; height: 58px; display: grid; margin: 0 auto 23px; place-items: center; color: var(--gold); border-radius: 18px; background: var(--green-900); font: 700 2rem/1 "Manrope", sans-serif; transform: rotate(-8deg); }
.login-card h1 { margin: 7px 0 9px; font: 800 1.8rem/1.2 "Manrope", sans-serif; letter-spacing: -.045em; }
.login-card > p { margin: 0 auto 27px; color: var(--muted); font-size: .88rem; }
.login-card form { text-align: left; }
.login-card .primary-button { margin-top: 4px; }
.back-link { display: inline-block; margin-top: 22px; color: var(--muted); font-size: .78rem; text-decoration: none; }
.back-link:hover { color: var(--green-800); }
.input-with-button { position: relative; }
.input-with-button input { padding-right: 82px; }
.input-with-button button { position: absolute; top: 7px; right: 7px; height: 36px; padding: 0 9px; color: var(--green-800); border: 0; border-radius: 7px; background: var(--green-50); font-size: .7rem; font-weight: 700; cursor: pointer; }

.dashboard { padding-block: 44px 70px; }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.dashboard-heading h1 { margin: 14px 0 5px; font-size: clamp(2.1rem, 4vw, 3.5rem); }
.dashboard-heading p { margin: 0; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-top: 30px; }
.stat-card { position: relative; min-height: 148px; padding: 23px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 5px 15px rgba(7,42,35,.03); }
.stat-card::after { content: ""; position: absolute; right: -25px; bottom: -35px; width: 90px; height: 90px; border-radius: 50%; background: var(--green-50); }
.stat-card.stat-primary { color: #fff; border-color: var(--green-900); background: var(--green-900); }
.stat-card.stat-primary::after { background: rgba(255,255,255,.06); }
.stat-label { position: relative; z-index: 1; display: block; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat-primary .stat-label, .stat-primary small { color: rgba(255,255,255,.65); }
.stat-card strong { position: relative; z-index: 1; display: block; margin: 10px 0 0; font: 800 2.35rem/1 "Manrope", sans-serif; letter-spacing: -.06em; }
.stat-card small { position: relative; z-index: 1; color: #8b9895; font-size: .7rem; }
.backup-stat strong { margin-top: 15px; font-size: 1.15rem; letter-spacing: -.02em; }

.data-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-heading { padding: 24px 25px; border-bottom: 1px solid #edf1ef; }
.panel-heading h2 { margin: 0; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; }
.file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.secondary-button { min-height: 38px; padding: 0 13px; color: var(--green-800); border: 1px solid #d8e2de; background: #fff; font-size: .72rem; box-shadow: none; }
.secondary-button:hover { border-color: #aebfba; background: var(--green-50); }
.secondary-button.accent { color: #fff; border-color: var(--green-800); background: var(--green-800); }
.secondary-button.danger { color: var(--danger); border-color: #f0cdd0; }

.filters { display: grid; grid-template-columns: minmax(250px, 1fr) 210px; gap: 12px; padding: 15px 25px; background: #fafcfb; border-bottom: 1px solid #edf1ef; }
.filters input, .filters select { height: 42px; background: #fff; font-size: .78rem; }
.search-field { position: relative; }
.search-field > span:not(.sr-only) { position: absolute; z-index: 1; top: 7px; left: 13px; color: #889591; font-size: 1.15rem; }
.search-field input { padding-left: 38px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; color: #778580; background: #fff; border-bottom: 1px solid #edf1ef; font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; color: #4f5e5a; border-bottom: 1px solid #edf1ef; font-size: .79rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.agent-cell { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.agent-avatar { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; color: var(--green-900); border-radius: 10px; background: var(--green-100); font-size: .7rem; font-weight: 800; }
.agent-name { display: flex; flex-direction: column; }
.agent-name strong { color: var(--ink); font-size: .8rem; text-transform: uppercase; }
.agent-name small { color: var(--muted); font-size: .72rem; }
.ucb-badge { display: inline-flex; padding: 5px 9px; color: var(--green-800); border-radius: 999px; background: var(--green-50); font-size: .69rem; font-weight: 700; white-space: nowrap; }
.actions-cell { display: flex; justify-content: flex-end; gap: 5px; }
.icon-button { width: 32px; height: 32px; display: grid; place-items: center; color: var(--green-800); border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.icon-button:hover { background: var(--green-50); }
.icon-button.delete { color: var(--danger); }
.icon-button.delete:hover { border-color: #f0cdd0; background: var(--danger-soft); }

.empty-state { padding: 65px 20px; text-align: center; }
.empty-state > span { display: block; color: #b7c4c0; font-size: 2.8rem; }
.empty-state h3 { margin: 8px 0 3px; font: 700 1.05rem "Manrope", sans-serif; }
.empty-state p { margin: 0 0 10px; color: var(--muted); font-size: .8rem; }
.text-link { color: var(--green-800); font-size: .78rem; font-weight: 700; text-decoration: none; }

.backup-tip { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 18px; padding: 18px 22px; color: #68562f; border: 1px solid #ead7ae; border-radius: 14px; background: #fff9ec; }
.backup-tip > div { display: flex; align-items: center; gap: 13px; }
.backup-tip > div > span { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; color: #fff; border-radius: 50%; background: var(--gold); font-family: serif; font-weight: 800; }
.backup-tip p { margin: 0; font-size: .76rem; line-height: 1.5; }
.backup-tip button { flex: 0 0 auto; padding: 8px 12px; color: #6f5622; border: 1px solid #dfc78e; border-radius: 8px; background: #fff; font-size: .7rem; font-weight: 700; cursor: pointer; }

.edit-dialog { width: min(650px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.edit-dialog::backdrop { background: rgba(5, 27, 23, .64); backdrop-filter: blur(3px); }
.edit-dialog form { padding: 28px; }
.dialog-heading { margin-bottom: 25px; }
.dialog-close { width: 35px; height: 35px; color: var(--muted); border: 0; border-radius: 8px; background: #f1f4f3; font-size: 1.3rem; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 15px; padding-top: 18px; border-top: 1px solid var(--line); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 42px; }
  .hero-copy { text-align: center; }
  .hero-copy > p { margin-inline: auto; }
  .trust-list { justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  html { overflow-x: hidden; }
  body { overflow-wrap: anywhere; }
  .container { width: min(100% - 28px, 1180px); }
  .header-inner { min-height: 70px; gap: 10px; }
  .brand img { width: 38px; height: 38px; }
  .brand { min-width: 0; gap: 9px; }
  .brand strong { white-space: nowrap; }
  .brand small { display: none; }
  .main-nav { flex: 0 0 auto; margin-left: auto; }
  .nav-link { padding: 8px 9px; font-size: .76rem; }
  .nav-admin span { display: none; }
  .hero { min-height: auto; }
  .hero-grid { padding-block: 38px 50px; }
  .hero-copy h1 { font-size: clamp(2.5rem, 13vw, 4rem); }
  .hero-copy > p { font-size: .92rem; }
  .trust-list { gap: 10px 15px; }
  .form-card { padding: 25px 20px; border-radius: 20px; }
  .form-grid { grid-template-columns: 1fr; gap: 15px; }
  input, select { min-width: 0; font-size: 16px; }
  .record-count { display: none; }
  .footer-inner { justify-content: center; }
  .footer-inner span:last-child { display: none; }
  .dashboard { padding-block: 30px 50px; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .dashboard-heading h1 { font-size: 2.3rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 130px; padding: 18px; }
  .stat-card strong { font-size: 1.9rem; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .file-actions { justify-content: flex-start; }
  .filters { grid-template-columns: 1fr; }
  .table-wrap { padding: 14px; overflow: visible; background: #f7f9f8; }
  .table-wrap table, .table-wrap tbody { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 17px 14px;
    margin-bottom: 12px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(7,42,35,.04);
  }
  .table-wrap tbody tr:last-child { margin-bottom: 0; }
  .table-wrap tbody tr:hover { background: #fff; }
  .table-wrap td {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    border: 0;
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: #8a9693;
    font-size: .61rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .table-wrap td:first-child { grid-column: 1 / -1; }
  .table-wrap td:first-child::before { display: none; }
  .table-wrap .actions-cell {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #edf1ef;
  }
  .icon-button { width: 40px; height: 40px; }
  .empty-state { background: #fff; border-radius: 14px; }
  .backup-tip { align-items: stretch; flex-direction: column; gap: 14px; }
  .backup-tip button { align-self: flex-start; }
  .login-card { padding: 32px 22px; }
  .edit-dialog form { padding: 22px 18px; }
}

@media (max-width: 480px) {
  .container { width: min(100% - 22px, 1180px); }
  .main-nav .nav-link:first-child { display: none; }
  .hero-grid { padding-top: 30px; }
  .hero-copy h1 { margin-top: 17px; }
  .eyebrow { font-size: .66rem; }
  .trust-list { align-items: flex-start; flex-direction: column; width: max-content; max-width: 100%; margin: 25px auto 0; }
  .form-card { padding-inline: 16px; }
  .card-heading h2 { font-size: 1.32rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 118px; }
  .file-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .file-actions .secondary-button:last-of-type { grid-column: 1 / -1; }
  .filters, .panel-heading { padding-inline: 16px; }
  .table-wrap tbody tr { grid-template-columns: 1fr; }
  .table-wrap td, .table-wrap td:first-child, .table-wrap .actions-cell { grid-column: 1; }
  .agent-cell { min-width: 0; }
  .agent-name { min-width: 0; }
  .agent-name strong, .agent-name small { overflow-wrap: anywhere; }
  .backup-tip { padding: 16px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions .primary-button, .dialog-actions .secondary-button { width: 100%; }
}

@media (max-width: 360px) {
  .brand img { width: 34px; height: 34px; }
  .brand strong { font-size: .9rem; }
  .nav-link { padding-inline: 6px; font-size: .71rem; }
  .hero-copy h1 { font-size: 2.35rem; }
  .form-card { border-radius: 16px; }
  .file-actions { grid-template-columns: 1fr; }
  .file-actions .secondary-button:last-of-type { grid-column: auto; }
}

@media print {
  .site-header, .dashboard-heading .primary-button, .file-actions, .filters, .backup-tip, .actions-cell, .toast { display: none !important; }
  body, .admin-body { background: #fff; }
  .dashboard { padding: 0; width: 100%; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .backup-stat { display: none; }
  .data-panel { box-shadow: none; }
}
