:root {
  --ink: #241c18;
  --ink-soft: #5c5148;
  --paper: #f4efe8;
  --card: #fffaf4;
  --line: #e5d8c9;
  --rose: #9c4a42;
  --rose-deep: #7c3731;
  --gold: #8d6a3f;
  --sage: #3e6b56;
  --shadow: 0 18px 40px rgba(36, 28, 24, 0.08);
  --sidebar: 248px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(156, 74, 66, 0.08), transparent 60%),
    var(--paper);
}

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--ink);
  color: #f6efe6;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  margin-bottom: 28px;
}

.brand strong { display: block; font-size: 16px; letter-spacing: 0.02em; }
.brand small { color: #cbbbaa; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #c46b5a;
  color: white;
  font-weight: 700;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  color: #f3e7dc;
}

.nav a:hover, .nav a:focus-visible { background: rgba(255, 250, 244, 0.08); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 250, 244, 0.12);
  font-size: 14px;
}

.sidebar-foot a {
  color: #f0d2b0;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.linkish {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--rose);
  background: white;
  color: var(--rose-deep);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.linkish:hover { background: #f8ece8; }

.sidebar-foot .linkish {
  color: #fffaf4;
  border-color: rgba(255, 250, 244, 0.45);
  background: rgba(255, 250, 244, 0.08);
}

.sidebar-foot .linkish:hover { background: rgba(255, 250, 244, 0.16); }

.workspace { flex: 1; min-width: 0; }

.main { padding: 28px 32px 48px; }

.toast {
  margin: 16px 32px 0;
  background: #e7f3ea;
  color: #24553a;
  border-radius: 12px;
  padding: 12px 14px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 32px; line-height: 1.15; font-weight: 650; }
h2 { margin: 0 0 12px; font-size: 20px; }

.lede { margin: 8px 0 0; color: var(--ink-soft); max-width: 62ch; }

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid #241c18;
  background: #fff;
  color: #241c18;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover, button.btn:hover, a.btn:hover {
  background: #f3e7dc;
  color: #241c18;
}

.btn-primary, button.btn-primary, a.btn-primary {
  background: #7c3731;
  border-color: #5e2823;
  color: #fff;
}

.btn-primary:hover, button.btn-primary:hover, a.btn-primary:hover {
  background: #5e2823;
  border-color: #5e2823;
  color: #fff;
}

.btn-ghost {
  background: white;
  border-color: var(--rose);
  color: var(--rose-deep);
}

.btn-ghost:hover { background: #f8ece8; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card { padding: 16px 18px; }
.card span { display: block; color: var(--ink-soft); font-size: 13px; }
.card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.panel { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 14px; }
.stack { display: grid; gap: 14px; }
.stack input, .stack select, .stack textarea, .auth-form input { width: 100%; }

.filters, .form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  min-height: 42px;
  border: 1px solid #ddcfc0;
  background: white;
  border-radius: 12px;
  padding: 8px 12px;
}

textarea { min-height: 84px; resize: vertical; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(141, 106, 63, 0.45);
  outline-offset: 2px;
}

table.data, table.sheet {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.data th, table.data td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data th { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }

.num { text-align: right; white-space: nowrap; }
.muted { color: var(--ink-soft); }
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #f3e7d4;
  color: #6d4d28;
  font-size: 12px;
  font-weight: 600;
}
.tag.warn { background: #f8e4df; color: #8a3d36; }
.tag.ok { background: #e5f2ea; color: #246146; }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,.12);
  vertical-align: -2px;
}

.rule {
  background: #fff7ee;
  border: 1px solid #ead7bf;
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.rule ul { margin: 8px 0 0; padding-left: 18px; }

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

table.sheet { min-width: 1100px; font-size: 13px; }
table.sheet th, table.sheet td {
  border: 1px solid #eadfD2;
  padding: 6px;
  min-width: 74px;
  background: white;
}
table.sheet thead th { position: sticky; top: 0; z-index: 2; }
table.sheet thead tr:nth-child(2) th { top: 34px; }
table.sheet .day {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f7f1ea;
  min-width: 52px;
  text-align: center;
}
table.sheet thead .day { z-index: 3; }
table.sheet tfoot td, table.sheet tfoot th {
  background: var(--ink);
  color: white;
  font-weight: 700;
}
.cell-btn {
  width: 100%;
  min-height: 34px;
  border: 1px solid #c9b8a6;
  background: #fffdfb;
  color: var(--ink);
  font-weight: 650;
  text-align: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
}
.cell-btn:hover { background: #fff4ef; border-color: var(--rose); }
td.off { background: #f8ece8; color: #9a3b32; font-weight: 700; }
td.edited { box-shadow: inset 0 -2px 0 var(--gold); }

.bar-row, .day-bars { display: grid; gap: 8px; }
.bar-row { grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; }
.track { height: 10px; background: #f0e6da; border-radius: 99px; overflow: hidden; }
.track span { display: block; height: 100%; background: linear-gradient(90deg, #c46b5a, #8d6a3f); border-radius: inherit; }
.day-bars { grid-template-columns: repeat(31, minmax(0, 1fr)); align-items: end; height: 120px; }
.day-bars i {
  display: block;
  background: #c46b5a;
  border-radius: 6px 6px 2px 2px;
  min-height: 2px;
}

dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(480px, calc(100vw - 24px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(36, 28, 24, 0.46); }
.dialog-body { padding: 20px; display: grid; gap: 12px; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, rgba(36, 28, 24, 0.92), rgba(156, 74, 66, 0.75)),
    var(--ink);
}
.auth-card {
  width: min(440px, calc(100vw - 28px));
  background: var(--card);
  border-radius: 28px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 34px; }
.auth-form { display: grid; gap: 12px; margin-top: 18px; }
.hint { color: var(--ink-soft); font-size: 13px; }
.error { color: #9a3b32; background: #f8ece8; padding: 10px 12px; border-radius: 12px; }
.field-error { color: #9a3b32; font-size: 13px; font-weight: 500; }

.lines { display: grid; gap: 8px; }
.line {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 8px;
  align-items: center;
}
.preview-table td { font-size: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 16px; }

.empty {
  padding: 28px 8px;
  color: var(--ink-soft);
}

.check-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.check-list label { font-weight: 500; }

@media (max-width: 980px) {
  .cards, .grid-2, .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    flex-basis: auto;
    z-index: 5;
  }
  .shell { display: block; }
  .nav { flex-direction: row; overflow: auto; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { display: flex; gap: 12px; align-items: center; }
  .main { padding: 18px 14px 32px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 28px; }
}
