:root {
  --ink: #14221c;
  --forest: #1f3d2f;
  --leaf: #2f6b4a;
  --cream: #f6f1e8;
  --paper: #f3eee6;
  --line: #ddd4c6;
  --muted: #5c5a54;
  --terracotta: #b44a2a;
  --ok: #2f6b4a;
  --warn: #9a6b12;
  --bad: #a33b24;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink); font-size: 17px; }
h1,h2,h3 { font-family: var(--display); letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; }
a { color: var(--leaf); }

#gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(700px 300px at 50% 0%, #dce8df, var(--paper));
}
#gate .card {
  width: min(420px, 100%); background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 28px;
}
#gate h1 { margin: 0 0 8px; }
#gate p { color: var(--muted); }
#gate input { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line); letter-spacing: 0.3em; text-align: center; font-size: 1.4rem; }
.pin-warn { background: #efe4c8; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--forest); color: #f6f1e8;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px;
}
.top a, .top button.link {
  color: #f6f1e8; background: none; border: 0; text-decoration: none; cursor: pointer; font-weight: 700;
}
.top .brand { font-family: var(--display); font-size: 1.15rem; }

#view { width: min(1100px, calc(100% - 24px)); margin: 20px auto 48px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 800px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: block; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 18px; text-decoration: none; color: inherit;
  min-height: 110px; cursor: pointer; text-align: left; width: 100%;
}
.tile:hover { border-color: var(--leaf); }
.tile b { display: block; font-size: 1.5rem; font-family: var(--display); }
.tile span { color: var(--muted); }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat b { font-size: 1.4rem; display: block; }
.stat span { color: var(--muted); font-size: 14px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; cursor: pointer; font-weight: 600;
}
.pill.on { background: var(--forest); color: #fff; border-color: var(--forest); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid transparent; background: var(--forest); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.tiny { min-height: 36px; padding: 4px 12px; font-size: 15px; }
.btn.danger { background: var(--terracotta); }

.list { display: grid; gap: 8px; }
.row {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; display: grid; gap: 4px; cursor: pointer; text-align: left; width: 100%;
}
.row:hover { border-color: var(--leaf); }
.muted { color: var(--muted); }
.fine { font-size: 14px; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 13px; font-weight: 700; background: var(--cream); }
.badge.warn { background: #efe4c8; color: var(--warn); }
.badge.bad { background: #f4d7d0; color: var(--bad); }
.badge.ok { background: #dce8df; color: var(--ok); }
.badge.sample { background: #e8e0f0; color: #4a3660; }

label { display: block; font-weight: 700; font-size: 14px; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff;
}
textarea { min-height: 90px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); }

.kanban { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .kanban { grid-template-columns: 1fr; } }
.col { background: #efebe3; border-radius: 14px; padding: 10px; min-height: 120px; }
.col h3 { margin: 0 0 8px; font-size: 1rem; }
.week { display: grid; gap: 8px; grid-template-columns: repeat(7, 1fr); }
@media (max-width: 900px) { .week { grid-template-columns: 1fr 1fr; } }
.day { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 110px; }
.day.today { border-color: var(--leaf); }
.day h4 { margin: 0 0 6px; font-size: 13px; }
.jobchip { background: var(--cream); border-radius: 8px; padding: 6px; margin-bottom: 6px; font-size: 14px; }

.templates { display: grid; gap: 12px; }
.templates textarea { min-height: 80px; }
.alert { background: #efe4c8; border-radius: 12px; padding: 12px; margin: 8px 0; }
.alert.bad { background: #f4d7d0; }
.notice { background: #dce8df; border-radius: 12px; padding: 12px; margin: 8px 0; }

@media print {
  .top, .toolbar, .no-print { display: none !important; }
  body { background: #fff; }
  #view { width: auto; margin: 0; }
  .invoice-print { box-shadow: none; border: 0; }
}
.invoice-print { background: #fff; padding: 24px; }
