:root {
  --bg: #f3f0e8;
  --bg-2: #e8e3d6;
  --ink: #1c2430;
  --muted: #5c6672;
  --line: #cfc7b6;
  --panel: #fffdf8;
  --brand: #0f4c5c;
  --brand-2: #16697a;
  --ok: #2f6f4e;
  --warn: #9a6700;
  --bad: #8b2e2e;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
  --radius: 14px;
  --font: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0f4c5c, #123844);
  color: #f4f7f8;
  padding: 1.25rem 1rem;
}
.sidebar .brand {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  display: block;
  margin-bottom: 0.35rem;
  text-decoration: none;
}
.sidebar-role {
  font-size: 0.78rem;
  color: #a8c4cc;
  margin-bottom: 1.1rem;
  padding: 0 0.15rem;
  letter-spacing: 0.02em;
}
.sidebar nav a {
  display: block;
  color: #d7e6ea;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  margin-bottom: 0.15rem;
  text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar nav a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}
.nav-group { margin-bottom: 0.85rem; }
.nav-group-end { margin-top: 1.2rem; padding-top: 0.6rem; border-top: 1px solid rgba(255,255,255,0.12); }
.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8fadb6;
  padding: 0 0.7rem 0.35rem;
  font-weight: 700;
}
.main { padding: 1.25rem 1.5rem 2.5rem; }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
}
.breadcrumbs a { color: var(--brand-2); }
.breadcrumbs .sep { opacity: 0.55; }
.breadcrumbs .current { color: var(--ink); font-weight: 600; }
.glossary { margin-bottom: 1rem; }
.glossary-title {
  font-size: 1rem;
  margin-bottom: 0.55rem;
  color: var(--brand);
}
.glossary-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}
.glossary-list > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.65rem;
  align-items: baseline;
}
.glossary-list dt {
  margin: 0;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--brand);
}
.glossary-list dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.workflow {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}
.workflow li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  box-shadow: var(--shadow);
}
.workflow-n {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.workflow-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.workflow-body a, .workflow-body strong {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  text-decoration: none;
}
.workflow-body a:hover { color: var(--brand-2); text-decoration: underline; }
.workflow-body .muted { font-size: 0.82rem; }
.form-section {
  margin: 0 0 1rem;
  padding: 0 0 0.4rem;
  border: none;
  border-bottom: 1px solid var(--line);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; }
.form-section legend {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--brand);
  padding: 0;
  margin-bottom: 0.35rem;
}
.form-section .section-help {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.badge.new, .badge.contacting { background: #dce9ee; color: var(--brand); }
.badge.replied { background: #d9efe3; color: var(--ok); }
.badge.skipped, .badge.paused, .badge.archived, .badge.on_hold, .badge.cancelled { background: #ece8df; color: var(--muted); }
.more-actions { position: relative; display: inline-block; }
.more-actions > summary {
  list-style: none;
  cursor: pointer;
}
.more-actions > summary::-webkit-details-marker { display: none; }
.more-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.4rem;
  z-index: 20;
  display: grid;
  gap: 0.15rem;
}
.more-actions-menu a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.more-actions-menu a:hover { background: var(--bg-2); }
.topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
h1,h2,h3 { font-family: var(--font); margin: 0 0 0.4rem; }
.muted { color: var(--muted); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat strong { display: block; font-size: 1.5rem; font-family: var(--font); }
.btn, button.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff !important;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none !important;
}
.btn.secondary { background: transparent; color: var(--brand) !important; border: 1px solid var(--line); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.94rem; }
th { color: var(--muted); font-size: 0.82rem; }
label { display: block; font-weight: 600; margin: 0.7rem 0 0.25rem; }
input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}
input[type=checkbox], input[type=radio] { width: auto; display: inline-block; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 0.9rem; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; align-items: end; }
.super-search label { margin-top: 0; }
.super-search-row { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; margin-top: 0.35rem; }
.super-search-row input {
  flex: 1 1 240px;
  font-size: 1.05rem;
  padding: 0.7rem 0.85rem;
  border: 2px solid var(--brand);
}
.grid.two-box { grid-template-columns: 1fr 1fr; }
.box-panel h2 { font-size: 1.15rem; }
.inventory-box {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.35;
  min-height: 280px;
  white-space: pre;
}
@media (max-width: 900px) {
  .grid.two-box { grid-template-columns: 1fr; }
}
.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--bg-2);
}
.badge.agreed, .badge.completed, .badge.active { background: #d9efe3; color: var(--ok); }
.badge.sent, .badge.processing { background: #fff1cc; color: var(--warn); }
.badge.rejected, .badge.blocked { background: #f3d6d6; color: var(--bad); }
.badge.draft, .badge.negotiating { background: #dce9ee; color: var(--brand); }
.folders { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }
.folder {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.folder:hover { border-color: var(--brand-2); text-decoration: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.9rem 0; }
.tabs a {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.messages { list-style: none; padding: 0; }
.messages li { padding: 0.7rem 0.9rem; border-radius: 10px; margin-bottom: 0.7rem; background: #e7f5ef; border: 1px solid #b7dcc8; }
.messages li.error { background: #f8e4e4; border-color: #e0b1b1; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.8rem;
}
.login-card h1 { font-size: 2rem; color: var(--brand); }
.help { font-size: 0.88rem; color: var(--muted); }
.history-item { border-left: 3px solid var(--brand-2); padding-left: 0.7rem; margin-bottom: 0.7rem; }
.checkbox-list { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 0.5rem; }
.checkbox-list label { font-weight: 500; display: flex; gap: 0.5rem; align-items: flex-start; }
.checkbox-list input { width: auto; margin-top: 0.2rem; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .glossary-list > div { grid-template-columns: 1fr; gap: 0.15rem; }
}
