*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #252836;
  --border: #2e3245;
  --text: #e2e4ed;
  --text-muted: #7b7f96;
  --primary: #4f6ef7;
  --primary-hover: #3d5ae0;
  --danger: #e05252;
  --danger-hover: #c43d3d;
  --success: #3ecf8e;
  --warning: #f5a623;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Auth card */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-card--wide { max-width: 560px; }

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--primary);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.625rem 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--primary);
}

.form-group small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { font-size: 0.8rem; padding: 0.35rem 0.75rem; }

.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* Alerts */
.alert {
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
}

.alert-error { background: rgba(224,82,82,0.15); border: 1px solid rgba(224,82,82,0.4); color: #f08080; }
.alert-success { background: rgba(62,207,142,0.12); border: 1px solid rgba(62,207,142,0.35); color: #3ecf8e; }

/* Navbar */
.navbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  left: 0;
  padding: 0 1.5rem;
  position: fixed;
  right: 0;
  top: 0;
  height: 56px;
  z-index: 10;
}

.navbar-brand {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.navbar-logout { font-size: 0.875rem; }

/* Main layout */
.container {
  margin: 80px auto 2rem;
  max-width: 900px;
  padding: 0 1.5rem;
  width: 100%;
}

body:has(.navbar) {
  display: block;
  justify-content: unset;
  align-items: unset;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Table */
.table {
  border-collapse: collapse;
  width: 100%;
}

.table th,
.table td {
  padding: 0.875rem 1.25rem;
  text-align: left;
}

.table th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.table td {
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  border-radius: 4px;
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
}

.badge-success { background: rgba(62,207,142,0.15); color: var(--success); }
.badge-warning { background: rgba(245,166,35,0.15); color: var(--warning); }

/* Recovery codes */
.recovery-section h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.recovery-warning {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.recovery-codes {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, 1fr);
  padding: 1rem;
}

.recovery-code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

/* QR code */
.qr-container {
  text-align: center;
  margin: 1.25rem 0;
}

.qr-container img { border-radius: 6px; max-width: 200px; }

.manual-key {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
  text-align: center;
  word-break: break-all;
}

.manual-key code {
  display: block;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  margin-top: 0.35rem;
  color: var(--text);
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* =============================================
   Admin layout with sidebar
   ============================================= */

.admin-layout {
  display: flex;
  margin-top: 56px;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  height: calc(100vh - 56px);
  left: 0;
  overflow-y: auto;
  padding: 1.25rem 0;
  position: fixed;
  top: 56px;
  width: 220px;
  z-index: 5;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li + li { margin-top: 2px; }

.sidebar-nav a {
  align-items: center;
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 0.625rem;
  margin: 0 0.75rem;
  padding: 0.625rem 0.875rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(79, 110, 247, 0.08);
  color: var(--text);
}

.sidebar-nav a.active {
  background: rgba(79, 110, 247, 0.12);
  color: var(--primary);
}

.admin-content {
  flex: 1;
  margin-left: 220px;
  min-height: calc(100vh - 56px);
  padding: 2rem 2.5rem;
}

/* =============================================
   Data table widget
   ============================================= */

/* Top bar: search toolbar sitting inside the card */
.dt-top {
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0.75rem 1.25rem;
}

.dt-search-wrap {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  transition: border-color 0.15s;
  width: 240px;
}

.dt-search-wrap:focus-within { border-color: var(--primary); }

.dt-search-icon {
  color: var(--text-muted);
  display: flex;
  flex-shrink: 0;
}

.dt-search-input {
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  width: 100%;
}

/* Bottom bar */
.dt-bottom-left {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.dt-pagesize-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.dt-pagesize-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  margin: 0 0.25rem;
  padding: 0.25rem 0.4rem;
}

.dt-bottom {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
}

.dt-info {
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding-left: 1rem;
}

.dt-pagination { display: flex; gap: 4px; }

.dt-page-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  line-height: 1;
  min-width: 30px;
  padding: 0.3rem 0.5rem;
  transition: background 0.15s, color 0.15s;
}

.dt-page-btn:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
}

.dt-page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.dt-page-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { color: var(--text); }

th.sorted { color: var(--primary); }

.sort-icon {
  display: inline-block;
  font-size: 0.7rem;
  margin-left: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  vertical-align: middle;
}

th.sortable:hover .sort-icon { opacity: 0.4; }

th.sorted .sort-icon { opacity: 1; }

/* =============================================
   Expandable rows
   ============================================= */

.expand-col {
  width: 36px;
  padding-left: 1rem !important;
  padding-right: 0 !important;
}

.expand-icon {
  color: var(--text-muted);
  display: inline-block;
  font-size: 0.6rem;
  transition: color 0.15s;
  vertical-align: middle;
}

.project-row { cursor: pointer; }

.project-row:hover td { background: rgba(79, 110, 247, 0.04); }

.project-row:hover .expand-icon { color: var(--text); }

.detail-link-row { cursor: pointer; }

.detail-link-row td {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.detail-link-row:hover td { background: rgba(79, 110, 247, 0.07); }

.detail-name { padding-left: 1.5rem !important; }

/* =============================================
   Toggle switch (Mark Done)
   ============================================= */

.toggle-switch {
  cursor: pointer;
  display: inline-block;
  height: 22px;
  position: relative;
  width: 42px;
}

.toggle-switch input { height: 0; opacity: 0; width: 0; }

.toggle-slider {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: 0.2s;
}

.toggle-slider::before {
  background: var(--text-muted);
  border-radius: 50%;
  bottom: 3px;
  content: '';
  height: 14px;
  left: 3px;
  position: absolute;
  transition: 0.2s;
  width: 14px;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(62, 207, 142, 0.18);
  border-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
  background: var(--success);
  transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
  cursor: not-allowed;
  opacity: 0.5;
}

/* =============================================
   Feedback feed — content cell
   ============================================= */

.content-cell { max-width: 340px; }

.read-more-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  margin-left: 4px;
  padding: 0;
  white-space: nowrap;
}

.read-more-btn:hover { text-decoration: underline; }

/* =============================================
   Breadcrumb
   ============================================= */

.breadcrumb {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb span { margin: 0 0.35rem; }

/* =============================================
   Badge additions
   ============================================= */

.badge-danger { background: rgba(224, 82, 82, 0.15); color: var(--danger); }
.badge-info   { background: rgba(79, 110, 247, 0.15); color: var(--primary); }

/* =============================================
   Buttons — secondary
   ============================================= */

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover { background: var(--surface); color: var(--text); }

/* =============================================
   Feed actions cell
   ============================================= */

.actions-cell { white-space: nowrap; }

.actions-cell .btn + .btn { margin-left: 0.4rem; }

/* =============================================
   Inline type select
   ============================================= */

.type-cell { cursor: pointer; }

.type-select-inline {
  background: var(--surface-2);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  outline: none;
  padding: 0.2rem 0.4rem;
}

/* =============================================
   Comments modal
   ============================================= */

.modal-overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  width: 520px;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.25rem;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  padding: 1.25rem;
}

.comments-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 80px;
  overflow-y: auto;
}

.comment-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.875rem;
}

.comment-text {
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.comment-form {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1rem;
}

.comment-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  min-height: 80px;
  outline: none;
  padding: 0.625rem 0.875rem;
  resize: vertical;
  transition: border-color 0.15s;
  width: 100%;
}

.comment-input:focus { border-color: var(--primary); }

/* =============================================
   Notifications admin pages
   - Override body's vertical centering so tall pages flow from the top
     instead of overflowing the viewport at the top edge.
   - Provide a full-width form layout used by project/caller forms.
   ============================================= */

body:has(.admin-layout) {
  justify-content: flex-start;
  align-items: stretch;
}

.admin-layout { width: 100%; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header .page-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
}

.form-card + .form-card { margin-top: 1.25rem; }

.form-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.form-grid .form-group { margin-bottom: 0; }

.form-grid .form-group.full { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.625rem 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); }

.form-group textarea.mono {
  font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.form-actions {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.form-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.checkbox-row input[type="checkbox"] { width: 1rem; height: 1rem; cursor: pointer; }

/* Send Logs table — centered headers and cells, wide audit-note column */
.notif-logs-table th,
.notif-logs-table td {
  text-align: center;
  vertical-align: middle;
}

.notif-logs-table .audit-col {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.8rem;
  min-width: 360px;
  max-width: 640px;
}
