:root {
  --ink: #17211f;
  --muted: #5b6865;
  --line: #d9e0dd;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --accent: #1f5f5b;
  --accent-dark: #164641;
  --accent-soft: #e6f0ed;
  --warn: #8a5a12;
  --shadow: 0 10px 30px rgba(24, 45, 40, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent-dark); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.6rem; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); margin-top: 2rem; }
h3 { font-size: 1.2rem; margin-top: 1.5rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }

.shell { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  background: var(--ink); color: white; padding: 0.7rem 1rem; border-radius: 0 0 8px 8px;
}
.skip-link:focus { top: 0; }
.site-header, .staff-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.header-inner, .staff-header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 72px; flex-wrap: wrap;
}
.brand { font-weight: 800; letter-spacing: -0.03em; text-decoration: none; color: var(--ink); font-size: 1.15rem; }
.brand span { color: var(--accent); font-weight: 600; }
.brand-inverse { color: white; }
.brand-inverse span { color: #9fd8cd; }
.site-header nav, .staff-header nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; font-size: 0.94rem; }
.site-header nav a, .staff-header nav a { text-decoration: none; font-weight: 600; }
.site-header nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; }
.staff-header { background: #17211f; color: white; }
.staff-header nav a { color: #e7efec; }
.staff-header nav a[aria-current="page"] { color: #9fd8cd; text-decoration: underline; }
.staff-who { color: #b7c6c1; font-size: 0.85rem; }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--line); background: var(--panel); }
.footer-inner { padding: 1.6rem 0; font-size: 0.9rem; color: var(--muted); display: grid; gap: 0.4rem; }

.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 2rem; }
.hero-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 2rem; align-items: start; }
.hero .lede { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; font-weight: 800; color: var(--accent); margin-bottom: 0.6rem; }
.hero-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.hero-panel ul { margin: 0; }
.hero-panel li { margin-bottom: 0.55rem; }

.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--accent); color: white; border: 1px solid var(--accent);
  border-radius: 8px; padding: 0.72rem 1.1rem; font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; min-height: 44px;
}
.button:hover, button:hover { background: var(--accent-dark); color: white; }
.button.secondary { background: transparent; color: var(--accent-dark); }
.button.secondary:hover { background: var(--accent-soft); }
.button.small, button.small { padding: 0.45rem 0.7rem; min-height: 36px; font-size: 0.9rem; }
.button-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }

.search-form { display: flex; gap: 0.6rem; margin: 1.4rem 0; max-width: 760px; }
.search-form input { flex: 1; }
input, select, textarea {
  width: 100%; border: 1px solid #b9c5c1; border-radius: 8px;
  background: white; color: var(--ink); font: inherit; padding: 0.7rem 0.8rem;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #7fc7b8; outline-offset: 2px;
}
textarea { min-height: 160px; resize: vertical; }
label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.field { margin-bottom: 1.1rem; }
.hint { color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 0.35rem; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }


.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.2rem, 3vw, 2rem); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1.2rem; }
.narrow { max-width: 760px; }
.page-head { padding: 2rem 0 1rem; }
.section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; flex-wrap: wrap; margin: 2rem 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; display: flex; flex-direction: column; }
.card h3 { margin-top: 0; }
.card .card-link { margin-top: auto; font-weight: 700; }
.card:hover { border-color: #a9bdb7; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { font-weight: 700; text-decoration: none; }
.article-list { display: grid; gap: 0; }
.article-list a { display: block; padding: 1rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.article-list a:hover { background: #f1f5f2; }
.article-list strong { display: block; }
.prose { max-width: 74ch; }
.prose h2, .prose h3 { margin-top: 1.6rem; }
.prose p, .prose li { color: #2b3835; }

.app-badge { display: inline-block; border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.78rem; font-weight: 800; background: #eef4f2; color: var(--accent-dark); border: 1px solid #c8d9d4; }
.badge { display: inline-block; border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.76rem; font-weight: 800; text-transform: capitalize; background: #eef1ee; color: #394743; white-space: nowrap; }
.status-new { background: #e8effa; color: #1d4f91; }
.status-in_progress { background: #fff1d6; color: #7b4d00; }
.status-waiting_customer { background: #efe9fb; color: #5b3b91; }
.status-resolved { background: #e4f4e9; color: #23633a; }
.priority-high { background: #fff1d6; color: #7b4d00; }
.priority-urgent { background: #fde5e5; color: #8a1f1f; }
.notice { border-radius: 8px; padding: 0.85rem 1rem; margin: 1rem 0; border: 1px solid #b9d4cb; background: #eef7f3; }
.notice.warn { border-color: #e5c98f; background: #fff8e8; }
.notice.error { border-color: #e5aeae; background: #fff0f0; }
.notice.ok { border-color: #9fd0ae; background: #eef8f1; }
.sensitive { border-left: 4px solid var(--warn); background: #fff8e8; padding: 0.9rem 1rem; border-radius: 0 8px 8px 0; }
.case-number { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.18rem; font-weight: 800; letter-spacing: 0.04em; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Staff */
.staff-main { padding: 1.5rem 0 4rem; }
.staff-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem; }
.filters select { width: auto; min-width: 9rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 0.75rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: #f2f5f2; }
tr:last-child td { border-bottom: 0; }
td .subject { font-weight: 700; }
.case-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr); gap: 1.2rem; align-items: start; }
.conversation { display: grid; gap: 0.9rem; }
.message { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; background: white; }
.message.inbound { border-left: 4px solid #7aa6c9; }
.message.outbound { border-left: 4px solid var(--accent); }
.message.note { background: #fff8e8; border-color: #e5c98f; }
.message.system { background: #f2f5f2; color: var(--muted); font-size: 0.9rem; }
.message-meta { display: flex; justify-content: space-between; gap: 0.7rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; flex-wrap: wrap; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.case-meta { display: grid; gap: 0.7rem; }
.case-meta dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 800; }
.case-meta dd { margin: 0; }
.actions { display: grid; gap: 0.8rem; }
.actions form { display: grid; gap: 0.5rem; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.audit-list { font-size: 0.85rem; color: var(--muted); }
.audit-list li { margin-bottom: 0.45rem; }
.login-wrap { max-width: 460px; margin: 3rem auto; }
.login-wrap h1 { font-size: 2rem; }

@media (max-width: 860px) {
  .hero-grid, .case-layout, .grid, .grid.two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .header-inner, .staff-header-inner { padding: 0.7rem 0; }
  .site-header nav, .staff-header nav { gap: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
