:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #17191c;
  --muted: #64748b;
  --line: #e4e4e7;
  --brand: #0f766e;
  --brand-soft: #ccfbf1;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --busy: #cbd5e1;
  --busy-text: #475569;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 390px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}
.brand-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

/* LAYOUT */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 18px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-size: 13.5px;
}
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}
.section-block { margin-bottom: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card h4 { margin: 8px 0; font-size: 14px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 880px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* FORMS & BUTTONS */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: #334155; }
input[type="text"], input[type="password"], input[type="date"], input[type="time"],
input[type="month"], input[type="number"], input[type="tel"], input[type="search"],
select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.input-sm { padding: 6px 8px !important; font-size: 13px !important; }
.stack-form { display: flex; flex-direction: column; gap: 11px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #0d5e58; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-outline.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.btn-icon { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }

/* LEGEND & TIMELINE */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.dot-mine { background: var(--brand); }
.dot-eri { background: var(--blue); }
.dot-manual { background: var(--warn); }
.dot-hold { background: #eab308; }
.dot-busy { background: var(--busy); }

.timeline-card { overflow-x: auto; padding: 12px; }
.tl-grid { min-width: 760px; }
.tl-header {
  display: grid;
  grid-template-columns: 135px 1fr;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 6px;
}
.tl-hours {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  font-size: 11px;
  color: var(--muted);
  text-align: left;
}
.tl-row {
  display: grid;
  grid-template-columns: 135px 1fr;
  align-items: center;
  min-height: 54px;
  border-bottom: 1px dashed var(--line);
}
.tl-room-cell { padding-right: 8px; }
.tl-room-name { font-weight: 700; font-size: 13px; }
.tl-clean-tag { font-size: 11px; display: inline-block; margin-top: 2px; }
.tl-track {
  position: relative;
  height: 44px;
  background: repeating-linear-gradient(
    to right,
    transparent,
    transparent calc(100% / 16 - 1px),
    #f1f5f9 calc(100% / 16 - 1px),
    #f1f5f9 calc(100% / 16)
  );
  border-radius: 6px;
  cursor: pointer;
}
.tl-bar {
  position: absolute;
  top: 4px;
  height: 36px;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}
.tl-bar.mine { background: var(--brand); color: #fff; cursor: pointer; }
.tl-bar.host-other { background: #334155; color: #fff; cursor: pointer; }
.tl-bar.eri { background: var(--blue-soft); color: #1d4ed8; border: 1.5px dashed var(--blue); cursor: pointer; }
.tl-bar.manual { background: var(--warn-soft); color: #92400e; border: 1.5px solid var(--warn); cursor: pointer; }
.tl-bar.hold { background: #fef9c3; color: #854d0e; border: 1.5px dashed #ca8a04; cursor: pointer; }
.tl-bar.busy { background: var(--busy); color: var(--busy-text); cursor: not-allowed; }
.tl-bar.block-host { background: #fce7f3; color: #9d174d; border: 1.5px dashed #db2777; }
.tl-turn {
  position: absolute;
  top: 4px;
  height: 36px;
  background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 4px, #f8fafc 4px, #f8fafc 8px);
  border-radius: 0 6px 6px 0;
  z-index: 1;
  pointer-events: none;
}

/* TABLES & PILLS */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafaf9; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.pill-green { background: var(--brand-soft); color: var(--brand); }
.pill-warn { background: var(--warn-soft); color: #92400e; }
.pill-red { background: var(--danger-soft); color: var(--danger); }
.pill-blue { background: var(--blue-soft); color: #1d4ed8; }
.pill-gray { background: #e2e8f0; color: #475569; }
.summary-pill { background: var(--brand-soft); color: var(--brand); font-weight: 700; padding: 6px 12px; border-radius: 99px; font-size: 13px; }

/* KPIS & ANALYTICS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.kpi-val { font-size: 20px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--muted); }
.delta-up { color: #059669; font-weight: 700; }
.delta-down { color: #dc2626; font-weight: 700; }

.progress-wrap { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.progress-bar-bg { height: 14px; background: #e2e8f0; border-radius: 99px; overflow: hidden; position: relative; margin: 8px 0; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #0f766e, #14b8a6); border-radius: 99px; transition: width 0.3s; }

.action-card {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  padding: 13px 15px;
  margin-bottom: 10px;
}
.action-card.high { background: #fef2f2; border-color: #fca5a5; border-left-color: var(--danger); }
.action-fw { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.action-title { font-weight: 700; font-size: 14px; margin: 3px 0; }
.action-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.filter-bar { margin-bottom: 14px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.room-checks { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.room-checks label { flex-direction: row; align-items: center; gap: 4px; font-weight: 500; }

/* HEATMAP */
.hm-table { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 11px; }
.hm-table th, .hm-table td { border: none; padding: 4px; text-align: center; border-radius: 4px; }
.hm-cell { min-width: 24px; height: 24px; font-weight: 600; font-size: 10.5px; }

/* MODAL & ALERTS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 18px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; }
.modal-footer { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

.preset-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.quote-box {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 10px 12px;
}
.quote-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.quote-head strong { font-size: 18px; color: var(--brand); }

.toggle-line { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.manual-box {
  margin-top: 8px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.alert-warn { background: var(--warn-soft); color: #92400e; padding: 9px 11px; border-radius: 8px; font-size: 12.5px; }
.alert-err { background: var(--danger-soft); color: var(--danger); padding: 9px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }

.check-box-group { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.check-box-group label { flex-direction: row; align-items: center; gap: 5px; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
