:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #18262d;
  --muted: #68757c;
  --line: #dce2df;
  --brand: #315f72;
  --brand-2: #477c62;
  --warn: #9a5b2f;
  --danger: #9a3f3f;
  --soft: #edf3f0;
  --planner: #f8fafb;
  --orange: #f28a3d;
  --blue: #2f7dbd;
  --green: #4b8f69;
  --violet: #7a63b8;
  --shadow: 0 14px 34px rgba(30, 45, 52, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  padding: 11px 14px;
  min-height: 42px;
  cursor: pointer;
}
button.secondary { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.compact { min-height: 34px; padding: 7px 10px; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
  min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.mark {
  width: 38px; height: 38px; border-radius: 8px; background: var(--brand);
  display: grid; place-items: center; color: white; font-weight: 800;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav {
  display: grid;
  gap: 6px;
  margin-top: 20px;
}
.nav button {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}
.nav button.active {
  background: var(--soft);
  border-color: var(--line);
  color: var(--brand);
}
.content { padding: 22px; max-width: 1220px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(30, 45, 52, .04);
}
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.metric { font-size: 28px; font-weight: 800; margin-top: 8px; }
.list { display: grid; gap: 10px; }
.item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.schedule {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.planner-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}
.planner-head h2 { margin-bottom: 4px; }
.schedule-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px;
  gap: 10px;
  min-width: min(520px, 100%);
}
.planner-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.planner-stats div {
  border: 1px solid var(--line);
  background: var(--planner);
  border-radius: 8px;
  padding: 10px 12px;
}
.planner-stats strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}
.planner-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.day-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.day-strip div {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
}
.day-strip strong,
.day-strip span { display: block; }
.day-strip span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.schedule-table-wrap { overflow-x: auto; }
.planner-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 68vh;
}
.schedule-table { min-width: 820px; }
.edit-shift-table { min-width: 1100px; }
.edit-shift-table input,
.edit-shift-table select {
  min-height: 36px;
  padding: 7px 8px;
  margin-bottom: 6px;
}
.edit-shift-table td { min-width: 120px; }
.edit-shift-table td:last-child {
  min-width: 150px;
  white-space: nowrap;
}
.schedule-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f8f7;
  border-bottom: 1px solid #cfd8d5;
}
.schedule-table tbody tr:nth-child(even) { background: #fbfcfb; }
.schedule-table tbody tr:hover { background: #eef5f3; }
.schedule-table th:nth-child(1), .schedule-table td:nth-child(1) { width: 14%; white-space: nowrap; }
.schedule-table th:nth-child(2), .schedule-table td:nth-child(2) { width: 22%; }
.schedule-table th:nth-child(3), .schedule-table td:nth-child(3),
.schedule-table th:nth-child(4), .schedule-table td:nth-child(4) { width: 10%; white-space: nowrap; }
.schedule-table th:nth-child(5), .schedule-table td:nth-child(5) { width: 18%; }
.schedule-table th:nth-child(7), .schedule-table td:nth-child(7) { width: 88px; text-align: right; }
.date-pill {
  display: inline-flex;
  align-items: center;
  min-width: 82px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #eef3f6;
  color: #2b5261;
  font-weight: 750;
}
.time-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 5px 7px;
  border-radius: 8px;
  background: #f2f4f5;
  font-weight: 750;
}
.role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  font-weight: 750;
  max-width: 100%;
}
.role-service { background: var(--blue); }
.role-kitchen { background: var(--orange); }
.role-dish { background: var(--violet); }
.role-event { background: var(--green); }
.role-neutral { background: #6d7880; }
.dept-label { color: var(--muted); font-weight: 650; }
.employee-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}
.planner-config {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}
.planner-lists {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
  margin-top: 16px;
}
.membership-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.check-row input {
  width: auto;
  min-height: 0;
}
.badge-warn { background: #fff3cd; color: #856404; }
.action-cell { white-space: nowrap; }
dialog { border: none; border-radius: 12px; padding: 1.5rem; max-width: 460px; width: 100%; box-shadow: 0 8px 40px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 1rem; font-size: 1.1rem; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 500; margin-bottom: .6rem; }
dialog input, dialog select { margin: 0; }
.dialog-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.project-slot { display: flex; align-items: center; padding: .3rem 0; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; gap: .25rem; }
.role-check-grid { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.section-head { margin: .9rem 0 .35rem; font-size: .9rem; color: #444; border-bottom: 1px solid #eee; padding-bottom: .2rem; }
.avail-grid { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .25rem; }
.avail-row { display: flex; align-items: center; gap: .4rem; }
.avail-day { min-width: 72px; }
.avail-sep { color: #999; font-size: .8rem; }
.avail-row input[type=time] { width: 90px; padding: .3rem .4rem; }
.avail-row select { flex: 1; min-width: 0; padding: .3rem .4rem; }
.badge-avail { background: #e8f5e9; color: #2e7d32; font-size: .75rem; }
.role-dept { margin-bottom: .5rem; }
.role-dept strong { font-size: .8rem; color: #666; display: block; margin-bottom: .25rem; }
.role-check-label { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.role-check-label input[type=radio] { accent-color: #f28a3d; width: 14px; height: 14px; }
.role-check-label input[type=checkbox] { width: 14px; height: 14px; }
.invite-box {
  background: #e8f4ff;
  border: 1.5px solid #bbd8f5;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  line-height: 1.6;
  word-break: break-all;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.employee-form textarea,
.employee-form button {
  grid-column: span 3;
}
.day { min-width: 130px; background: #fafbf9; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.shift {
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border-left: 4px solid var(--brand-2);
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--soft);
  color: var(--brand);
  font-size: 12px;
  width: fit-content;
}
.clock-face {
  display: grid;
  place-items: center;
  min-height: 250px;
  text-align: center;
  background: linear-gradient(135deg, #ffffff, #eef4f1);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.clock-time { font-size: clamp(38px, 12vw, 72px); font-weight: 850; }
.terminal .app-shell { display: block; }
.terminal .sidebar, .terminal .topbar .user-actions { display: none; }
.terminal .content { max-width: 920px; padding: 24px; }
.terminal button { min-height: 68px; font-size: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 13px; }
tfoot th { color: var(--ink); background: var(--soft); }
.error { color: var(--danger); min-height: 20px; }

/* ── Admin tabs ── */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
.admin-tab { background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 8px 8px 0 0; min-height: 38px; padding: 7px 14px; }
.admin-tab.active { background: var(--brand); color: white; border-color: var(--brand); }
.admin-tab-content { }
/* ── 7-day strip ── */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.week-day-card { background: #fafcfb; border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 80px; }
.week-day-label { font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--brand); }
/* ── Timeline ── */
.tl-wrap { overflow-x: auto; }
.tl-row { display: flex; align-items: center; margin-bottom: 6px; }
.tl-name { min-width: 110px; max-width: 110px; font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.tl-track { position: relative; height: 32px; background: #f5f8f7; border-radius: 6px; overflow: visible; }
.tl-block { position: absolute; top: 4px; height: 24px; border-radius: 5px; cursor: pointer; overflow: hidden; opacity: .9; transition: opacity .15s; }
.tl-block:hover { opacity: 1; z-index: 2; }
.tl-label { font-size: 10px; color: white; font-weight: 600; white-space: nowrap; padding: 0 5px; line-height: 24px; display: block; overflow: hidden; }
.tl-header { font-size: 10px; color: var(--muted); }
.tl-hour { position: absolute; transform: translateX(-50%); }
/* ── Calendar ── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  min-width: 0;
}
.cal-head {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
}
.cal-cell {
  min-height: 90px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: background .1s;
}
.cal-cell:hover { background: #f4f9f7; }
.cal-cell.cal-empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.cal-today { border-color: var(--brand); background: #f0f7fb; }
.cal-day-num { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cal-today .cal-day-num { color: var(--brand); }
.cal-shift-count { font-size: 11px; background: var(--soft); color: var(--brand); border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; display: inline-block; }
.cal-event {
  font-size: 11px;
  border-radius: 4px;
  padding: 2px 5px;
  margin-bottom: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-time { font-weight: 700; color: #555; }
/* ── Events & Orders ── */
.ev-group { margin-bottom: 20px; }
.ev-group-head {
  font-weight: 700;
  font-size: .95rem;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: #f9f9f9;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.ev-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.ev-card:hover { border-color: #bbb; }
.order-chk { margin-top: 8px; }
.order-chk label { font-size: .85rem; cursor: pointer; }
dialog { max-width: 560px; }

@media (max-width: 860px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar {
    position: fixed;
    z-index: 10;
    left: 0; right: 0; bottom: 0; top: auto;
    height: auto;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 7px;
  }
  .sidebar .brand-row { display: none; }
  .nav { grid-template-columns: repeat(6, 1fr); margin: 0; gap: 4px; }
  .nav button { padding: 8px 4px; min-height: 48px; text-align: center; font-size: 12px; }
  .content { padding: 16px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .grid { display: block; }
  .panel { margin-bottom: 12px; }
  .row { align-items: stretch; }
  .row > * { flex: 1 1 160px; }
  .planner-head { display: grid; }
  .planner-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day-strip,
  .planner-config,
  .planner-lists,
  .membership-grid { grid-template-columns: 1fr; }
  .schedule-tools { grid-template-columns: 1fr; }
  .schedule-table { min-width: 760px; }
  .employee-form { grid-template-columns: 1fr; }
  .employee-form textarea,
  .employee-form button { grid-column: span 1; }
}
