:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #1b211d;
  --muted: #68706a;
  --line: #dfe3dc;
  --primary: #205c45;
  --primary-hover: #174735;
  --soft: #edf3ef;
  --danger: #a33b35;
  --warning: #9a651c;
  --shadow: 0 18px 50px rgba(25, 43, 34, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.045em; line-height: 1.05; margin-bottom: 14px; }
h2 { font-size: 1.35rem; letter-spacing: -.02em; margin-bottom: 8px; }
small { display: block; color: var(--muted); font-size: .78rem; margin-top: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 8px; }

.topbar {
  min-height: 76px;
  padding: 12px max(24px, calc((100vw - 1320px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand, .account { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand strong, .account strong { display: block; }
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  letter-spacing: -.04em;
}
.brand-mark-small { width: 42px; height: 42px; border-radius: 12px; }
.account { text-align: right; }
.account form { margin-left: 8px; }

.page { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 56px 0 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; margin-bottom: 34px; }
.page-heading > div:first-child { max-width: 760px; }
.role-note { max-width: 360px; padding: 16px 18px; border-left: 3px solid var(--primary); background: var(--soft); color: #425047; border-radius: 0 12px 12px 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stats article { padding: 20px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; }
.stats span { color: var(--muted); font-size: .86rem; }
.stats strong { display: block; margin-top: 8px; font-size: 2rem; line-height: 1; letter-spacing: -.04em; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.add-panel { padding: 26px; display: grid; grid-template-columns: .75fr 1.25fr; gap: 42px; align-items: center; margin-bottom: 22px; }
.add-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.add-form textarea { min-height: 116px; }
.table-panel { overflow: hidden; }
.table-toolbar { padding: 24px 26px; display: flex; align-items: end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

input, select, textarea {
  width: 100%;
  border: 1px solid #cdd3cc;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
label > span:not(.sr-only) { display: block; font-size: .86rem; font-weight: 700; margin-bottom: 6px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(32,92,69,.22);
  outline-offset: 2px;
  border-color: var(--primary);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { color: var(--primary); background: var(--soft); border-color: #d2e0d7; }
.button-secondary:hover { background: #e2ece6; }
.button-quiet { color: var(--muted); background: transparent; border-color: var(--line); }

.alert { padding: 13px 16px; border-radius: 11px; margin-bottom: 18px; font-weight: 650; }
.alert-error { color: #7d2d28; background: #fae9e7; border: 1px solid #efcbc7; }
.alert-success { color: #20583f; background: #e7f3eb; border: 1px solid #c6dfcf; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); background: #fafbf9; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfa; }
tbody tr.is-dirty { background: #fffaf0; }
tbody tr.is-dirty td:first-child { box-shadow: inset 3px 0 0 #d89128; }
button:disabled { cursor: wait; opacity: .65; }
td:nth-child(1) { min-width: 205px; }
td:nth-child(2) { min-width: 175px; }
td:nth-child(3) { min-width: 250px; }
.phone { color: var(--ink); font-weight: 800; text-decoration: none; font-variant-numeric: tabular-nums; }
.phone:hover { color: var(--primary); text-decoration: underline; }
.action-cell { width: 1%; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.badge-neutral { color: #526057; background: #edf0ed; }
.badge-success { color: #18633f; background: #ddf2e5; }
.badge-warning { color: #875816; background: #fff0d5; }
.badge-info { color: #285b83; background: #e1eff9; }
.badge-danger { color: #8c302b; background: #f8dfdc; }
.badge-muted { color: #625a6c; background: #eeeaf2; }
.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--soft); color: var(--primary); border-radius: 50%; font-size: 1.4rem; }
.pagination { padding: 18px 24px; display: flex; align-items: center; justify-content: center; gap: 14px; border-top: 1px solid var(--line); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #dfece4, transparent 32%), var(--bg); }
.login-card { width: min(440px, 100%); background: var(--surface); padding: 38px; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 28px; }
.login-card h1 { font-size: 2.35rem; }
.stack { display: grid; gap: 17px; margin-top: 28px; }
.stack .button { margin-top: 4px; }

@media (max-width: 900px) {
  .page-heading, .table-toolbar { align-items: stretch; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .add-panel { grid-template-columns: 1fr; gap: 18px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .topbar { padding: 10px 16px; }
  .brand small, .account span { display: none; }
  .account { gap: 0; }
  .page { width: min(100% - 24px, 1320px); padding-top: 34px; }
  .page-heading { margin-bottom: 24px; }
  .role-note { max-width: none; }
  .stats { gap: 8px; }
  .stats article { padding: 15px; }
  .stats strong { font-size: 1.65rem; }
  .add-panel, .table-toolbar { padding: 20px; }
  .add-form { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; width: 100%; }
  .filters label, .filters .button { width: 100%; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody tr { padding: 18px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td, td:nth-child(n) { min-width: 0; padding: 7px 0; border: 0; }
  td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
  .action-cell .button { width: 100%; margin-top: 6px; }
  .login-card { padding: 28px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
