/* Dark mode toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Logout button */
.logout-btn {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.logout-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.logout-btn svg {
  width: 18px;
  height: 18px;
}

/* Notification bell */
.notif-bell-wrap {
  position: relative;
}

.notif-bell {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.notif-bell:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.notif-bell svg {
  width: 18px;
  height: 18px;
}

.notif-bell-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notif-bell-count[hidden] {
  display: none;
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, 90vw);
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 40;
}

.notif-panel[hidden] {
  display: none;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.notif-panel-header h4 {
  margin: 0;
  font-size: 14px;
}

.notif-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.notif-panel-mark-all,
.notif-panel-clear {
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.notif-panel-clear {
  color: var(--text-muted);
}

.notif-panel-mark-all:hover,
.notif-panel-clear:hover {
  text-decoration: underline;
}

.notif-panel-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notif-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.notif-item:last-child {
  border-bottom: 0;
}

.notif-item.is-unread {
  background: var(--surface-strong);
}

.notif-item-message {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.notif-item-time {
  font-size: 11.5px;
  color: var(--text-faint);
}

.notif-panel-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn.btn-secondary:hover {
  background: var(--surface-strong);
}

.btn.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 0 8px;
  height: 32px;
}

.btn.btn-ghost:hover {
  background: rgba(78, 121, 255, 0.1);
}

.btn.btn-danger {
  background: var(--danger);
}

.btn.btn-danger:hover {
  background: #9c2233;
}

/* Access gate */
.access-page {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(78, 121, 255, 0.14), transparent 36%),
    linear-gradient(315deg, rgba(87, 217, 136, 0.18), transparent 34%),
    var(--bg);
}

.access-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.access-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.access-logo {
  width: 44px;
  height: 44px;
}

.access-copy {
  display: grid;
  gap: 6px;
}

.access-copy h1 {
  font-size: 24px;
}

.access-copy p {
  color: var(--text-muted);
}

.access-form {
  display: grid;
  gap: 12px;
}

.access-form .btn {
  width: 100%;
}

.access-error {
  color: var(--danger);
  font-size: 13px;
}

.btn.btn-accent {
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-blue));
}

.btn.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* KPI stat cards */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent-bar, var(--brand-blue));
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-sub {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* Badges & status pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-neutral {
  background: var(--neutral-bg);
  color: var(--text-muted);
}

.badge-dot-only::before {
  content: none;
}

/* Custom tooltip: add class="has-tip" + data-tip="..." (+ optional data-tip-tone="success|warning|danger|info|neutral")
   to any element. Rendering is handled by assets/js/tooltip.js — a single element positioned with
   `position: fixed` and appended to <body>, so it always renders above scroll/overflow containers
   like .table-wrap instead of being clipped or forcing a scrollbar. */
.tooltip-bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  width: max-content;
  max-width: 240px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
  box-shadow: var(--shadow-md);
  background: var(--tooltip-neutral-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tooltip-bubble.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--tooltip-neutral-bg);
  border-bottom-width: 0;
}

.tooltip-bubble--success { background: var(--tooltip-success-bg); color: var(--success); }
.tooltip-bubble--success::after { border-top-color: var(--tooltip-success-bg); }

.tooltip-bubble--warning { background: var(--tooltip-warning-bg); color: var(--warning); }
.tooltip-bubble--warning::after { border-top-color: var(--tooltip-warning-bg); }

.tooltip-bubble--danger { background: var(--tooltip-danger-bg); color: var(--danger); }
.tooltip-bubble--danger::after { border-top-color: var(--tooltip-danger-bg); }

.tooltip-bubble--info { background: var(--tooltip-info-bg); color: var(--info); }
.tooltip-bubble--info::after { border-top-color: var(--tooltip-info-bg); }

.tooltip-bubble--neutral { background: var(--tooltip-neutral-bg); color: var(--text-muted); }
.tooltip-bubble--neutral::after { border-top-color: var(--tooltip-neutral-bg); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: rgba(78, 121, 255, 0.04);
}

td.strong {
  font-weight: 600;
}

td.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Toolbar / filters */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.toolbar .field {
  margin: 0;
  min-width: 180px;
}

.toolbar-spacer {
  flex: 1;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}

.switch .track::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .track {
  background: var(--brand-blue);
}

.switch input:checked + .track::before {
  transform: translateX(18px);
}

.switch input:disabled + .track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 15px;
}

/* Progress bar */
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-teal), var(--brand-blue));
}

/* Tag / chip list */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.chip .chip-remove {
  cursor: pointer;
  color: var(--text-faint);
  font-weight: 700;
}

.chip .chip-remove:hover {
  color: var(--danger);
}

.chip .chip-edit {
  cursor: pointer;
  color: var(--text-faint);
}

.chip .chip-edit:hover {
  color: var(--text);
}

.chip .chip-unmerge {
  cursor: pointer;
  color: var(--text-faint);
  font-weight: 700;
}

.chip .chip-unmerge:hover {
  color: var(--accent, #5b6cff);
}

.chip.selectable {
  cursor: pointer;
}

.chip.selected {
  border-color: var(--accent, #5b6cff);
  background: var(--surface);
}

/* Side drawer — slides in from the right, e.g. a day's contents on the editorial calendar */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 10, 61, 0.35);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(400px, 92vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Modal / drawer */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 10, 61, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  overscroll-behavior: contain;
}

.overlay[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}

.icon-btn-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-strong);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.icon-btn-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 4px 0;
}

/* Callout / info note */
.callout {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--info-bg);
  color: var(--callout-info-text);
  font-size: 13px;
  border: 1px solid rgba(0, 152, 252, 0.2);
}

.callout.callout-warning {
  background: var(--warning-bg);
  color: var(--callout-warning-text);
  border-color: rgba(183, 121, 31, 0.25);
}

.callout.callout-success {
  background: var(--success-bg);
  color: var(--callout-success-text);
  border-color: rgba(29, 148, 121, 0.25);
}

.callout.callout-danger {
  background: var(--danger-bg);
  color: var(--callout-danger-text);
  border-color: rgba(192, 41, 63, 0.25);
}
