:root {
  --brand: oklch(0.58 0.16 250);
  --brand-dark: oklch(0.5 0.14 250);
  --brand-soft-bg: oklch(0.94 0.03 250);
  --brand-soft-text: oklch(0.4 0.13 250);
  --text-primary: oklch(0.18 0.02 250);
  --text-secondary: oklch(0.5 0.012 250);
  --text-tertiary: oklch(0.6 0.012 250);
  --bg-page: oklch(0.975 0.004 250);
  --bg-card: #fff;
  --border: oklch(0.9 0.008 250);
  --border-soft: oklch(0.93 0.006 250);
  --sidebar-bg: #fff;
  --danger: oklch(0.55 0.19 25);
  --danger-soft-bg: oklch(0.965 0.008 25);
  --danger-soft-text: oklch(0.5 0.13 60);
  --success-bg: oklch(0.93 0.08 150);
  --success-text: oklch(0.4 0.1 150);
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 100px;
  --shadow-card: 0 1px 2px rgba(20, 25, 40, 0.05);
  --shadow-float: 0 18px 50px -20px rgba(20, 25, 40, 0.18), 0 1px 2px rgba(20, 25, 40, 0.06);
  --font-sans: 'Gothic A1', 'IBM Plex Sans KR', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

:root[data-role="general"] [data-role-premium] { display: none !important; }
:root[data-role="premium"] [data-role-general] { display: none !important; }
:root[data-role="general"] #role-switch [data-set-role="general"],
:root[data-role="premium"] #role-switch [data-set-role="premium"] { background: #fff; color: var(--brand-soft-text); font-weight: 700; box-shadow: 0 1px 3px rgba(20,25,40,.12); }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 16px;
}
.sidebar-brand .badge-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff;
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-brand .org { font-size: 14.5px; font-weight: 800; color: var(--text-primary); }
.sidebar-brand .who { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.sidebar-group-label {
  padding: 10px 12px 2px;
  font-size: 10.5px; font-weight: 700; color: var(--text-tertiary); letter-spacing: 0.06em;
}
.sidebar a.nav-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
}
.sidebar a.nav-item:hover { background: var(--bg-page); }
.sidebar a.nav-item.active { background: var(--brand-soft-bg); color: var(--brand-soft-text); font-weight: 700; }
.sidebar a.nav-item .new-badge {
  font-size: 9px; font-weight: 700; background: var(--brand); color: #fff;
  padding: 2px 6px; border-radius: var(--radius-pill);
}
.sidebar-device {
  margin-top: auto;
  background: var(--bg-page);
  border-radius: 14px;
  padding: 14px 16px;
}
.sidebar-device .dot-row { display: flex; align-items: center; gap: 7px; }
.sidebar-device .dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: oklch(0.65 0.17 150); }
.sidebar-device .label { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.sidebar-device .clock { font-size: 11.5px; color: var(--text-secondary); margin-top: 8px; }
.sidebar-role-switch {
  margin-top: 10px;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}
.sidebar-role-switch .caption { font-size: 10.5px; color: var(--text-tertiary); margin-bottom: 6px; }
.role-pill-group { display: flex; background: var(--bg-page); border-radius: var(--radius-pill); padding: 3px; }
.role-pill-group button {
  flex: 1; border: none; background: none; padding: 7px 0; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
}
.role-pill-group button.active { background: #fff; color: var(--brand-soft-text); font-weight: 700; box-shadow: 0 1px 3px rgba(20,25,40,.12); }

.content { padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; max-width: 1080px; }
.page-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title h1 { font-size: 22px; font-weight: 800; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13.5px; font-weight: 700; padding: 11px 18px; border-radius: var(--radius-pill);
  border: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 24px -12px var(--brand); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-primary); }
.btn-soft { background: var(--brand-soft-bg); color: var(--brand-soft-text); border: none; }
.btn-danger-soft { background: #fff; border: 1px solid oklch(0.85 0.12 25); color: oklch(0.5 0.14 25); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { background: var(--border); color: var(--text-tertiary); box-shadow: none; cursor: not-allowed; }

/* ---------- card / grid ---------- */
.card { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-pad { padding: 20px 22px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card .label { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 5px; }
.stat-card.accent { background: var(--brand-soft-bg); }
.stat-card.accent .label, .stat-card.accent .value { color: var(--brand-soft-text); }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.field label .req { color: oklch(0.55 0.15 25); }
.field input, .field textarea, .field select {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 13.5px; font-family: inherit; color: var(--text-primary);
}
.field textarea { min-height: 120px; line-height: 1.7; resize: vertical; }
.field-flat { background: var(--bg-page); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--text-primary); }

/* ---------- tabs / chips ---------- */
.tabs { display: flex; background: var(--bg-page); border-radius: var(--radius-pill); padding: 3px; }
.tabs button { flex: 1; border: none; background: none; padding: 8px 0; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.tabs button.active { background: #fff; color: var(--brand-soft-text); font-weight: 700; box-shadow: 0 1px 3px rgba(20,25,40,.12); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg-page); border: none; color: var(--text-secondary); font-size: 12px; font-weight: 600; padding: 7px 13px; border-radius: var(--radius-pill); }
.chip.selected { background: var(--brand-soft-bg); color: var(--brand-soft-text); font-weight: 700; }
.day-chip { width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--bg-page); color: var(--text-secondary); font-size: 12.5px; font-weight: 600; border: none; }
.day-chip.selected { background: var(--brand); color: #fff; font-weight: 700; }

/* ---------- table ---------- */
.table-head, .table-row {
  display: grid; align-items: center; gap: 0; padding: 0 18px;
}
.table-head { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); }
.table-row { background: #fff; border-radius: 14px; padding: 14px 18px; font-size: 13px; box-shadow: var(--shadow-card); }
.table-row.dim { opacity: .55; }
.table-rows { display: flex; flex-direction: column; gap: 8px; }
.status-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--brand-soft-bg); color: var(--brand-soft-text); }
.status-badge.done { background: var(--border-soft); color: var(--text-secondary); }
.status-badge.active { background: var(--success-bg); color: var(--success-text); }
.row-actions { display: flex; gap: 8px; font-size: 12px; font-weight: 700; }
.row-actions .edit { color: var(--brand-dark); }
.row-actions .danger { color: oklch(0.55 0.14 25); }

/* ---------- filter pills ---------- */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-pill { background: #fff; border-radius: var(--radius-pill); padding: 9px 16px; font-size: 12.5px; color: var(--text-secondary); box-shadow: var(--shadow-card); border: none; }
.filter-pill.search { width: 180px; text-align: left; color: var(--text-primary); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 25, 40, .35);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: 100%; max-width: 440px; background: #fff; border-radius: 18px; padding: 26px 28px;
  box-shadow: 0 30px 70px -20px rgba(20, 25, 40, 0.4);
  display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto;
}
.modal-box .modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-box .modal-head h2 { font-size: 17px; font-weight: 800; margin: 0; }
.modal-close { background: none; border: none; font-size: 16px; color: var(--text-tertiary); }

/* ---------- premium gate ---------- */
.premium-gate {
  background: #fff; border-radius: var(--radius-lg); padding: 48px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: var(--shadow-card);
}
.premium-gate .icon { font-size: 28px; }
.premium-gate h2 { font-size: 18px; margin: 0; }
.premium-gate p { font-size: 13.5px; color: var(--text-secondary); margin: 0; max-width: 360px; }

/* ---------- emergency ---------- */
.emergency-shell { background: var(--danger-soft-bg); border-radius: var(--radius-lg); padding: 28px 32px; display: flex; flex-direction: column; gap: 16px; }
.emergency-badge { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: var(--radius-pill); }
.emergency-primary {
  background: var(--danger); border-radius: 18px; padding: 22px 24px; display: flex; align-items: center; gap: 16px; color: #fff;
  box-shadow: 0 12px 28px -14px var(--danger); border: none; text-align: left; width: 100%;
}
.emergency-primary .icon { width: 48px; height: 48px; border-radius: var(--radius-pill); background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.emergency-primary .title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.emergency-primary .sub { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 4px; }
.emergency-primary .go { font-size: 12px; font-weight: 700; background: #fff; color: var(--danger); padding: 9px 16px; border-radius: var(--radius-pill); margin-left: auto; flex-shrink: 0; }
.emergency-secondary {
  background: #fff; border-radius: 16px; padding: 18px 20px; display: flex; align-items: center; gap: 12px; border: none; width: 100%; text-align: left;
}
.emergency-secondary .icon { width: 38px; height: 38px; border-radius: var(--radius-pill); background: var(--bg-page); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.emergency-secondary .title { font-size: 15px; font-weight: 800; }
.emergency-secondary .sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.emergency-add-card {
  background: transparent; border: 2px dashed oklch(0.85 0.03 25); border-radius: 16px; padding: 18px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: oklch(0.5 0.05 25); width: 100%;
}
.emergency-flow { background: oklch(0.22 0.03 25); border-radius: 16px; padding: 18px 20px; color: #fff; }
.emergency-flow .cap { font-size: 11px; font-weight: 700; color: oklch(0.8 0.08 25); letter-spacing: 0.04em; }
.emergency-inline-form { background: #fff; border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- notice / toast ---------- */
.notice { font-size: 12.5px; color: var(--danger-soft-text); background: oklch(0.97 0.03 90); border-radius: 8px; padding: 10px 14px; }
.notice-blue { font-size: 12.5px; color: var(--brand-soft-text); background: var(--brand-soft-bg); border-radius: 8px; padding: 10px 14px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: #fff; padding: 13px 22px; border-radius: var(--radius-pill);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- misc ---------- */
.list-simple { display: flex; flex-direction: column; gap: 8px; }
.list-item { background: #fff; border-radius: 12px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; box-shadow: var(--shadow-card); }
.list-item.accent { background: var(--brand-soft-bg); color: var(--brand-soft-text); font-weight: 700; }
.section-label { font-size: 12.5px; font-weight: 800; }
.divider { height: 1px; background: var(--border-soft); }

/* ---------- login ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 960px; border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-page); box-shadow: var(--shadow-float); display: flex; min-height: 520px; }
.login-form-side { flex: 1; background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 0 56px; }
.login-info-side { flex: 1; background: var(--bg-page); display: flex; align-items: center; justify-content: center; padding: 40px; border-left: 1px solid var(--border-soft); }
.login-info-side .eyebrow { font-size: 12px; font-weight: 700; color: var(--brand-soft-text); letter-spacing: .14em; margin-bottom: 10px; }
.login-info-side .body { color: var(--text-secondary); font-size: 14px; line-height: 1.9; max-width: 280px; }
.login-demo { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 20px; }
  .login-card { flex-direction: column; min-height: 0; }
  .login-form-side { padding: 40px 28px; }
}
