/* =========================================================
   OptiFlow – Main Stylesheet
   Sections:
     1. Reset / Base
     2. CSS Variables (Light & Dark)
     3. Layout (Sidebar + Main)
     4. Topbar
     5. Auth layout
     6. Typography
     7. Forms
     8. Buttons
     9. Tables
    10. Cards / Stat Boxes
    11. Badges
    12. Alerts / Flash
    13. Detail / Info display
    14. Service Items
    15. Icons
    16. Utilities
    17. Responsive
   ========================================================= */

/* ── 1. Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 2. CSS Variables ──────────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --radius:    8px;
  --radius-sm: 5px;

  /* Accent palette */
  --accent:        #4361ee;
  --accent-dark:   #2f4bcd;
  --accent-subtle: #eef1fd;
  --success:       #16a34a;
  --success-subtle:#dcfce7;
  --danger:        #dc2626;
  --danger-subtle: #fee2e2;
  --warning:       #d97706;
  --warning-subtle:#fef3c7;
  --info:          #0369a1;
  --info-subtle:   #e0f2fe;

  /* Sidebar (same in both modes) */
  --sidebar-bg:          #111827;
  --sidebar-text:        #9ca3af;
  --sidebar-active-bg:   #1e293b;
  --sidebar-active-text: #f9fafb;
  --sidebar-hover-bg:    #1f2937;
  --sidebar-border:      rgba(255,255,255,.06);

  /* Light mode surface tokens */
  --bg:         #f3f4f8;
  --surface:    #ffffff;
  --surface-2:  #f8f9fc;
  --border:     #e5e7eb;
  --text:       #111827;
  --text-2:     #374151;
  --text-muted: #6b7280;
  --shadow:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09);
}

/* Dark mode overrides */
[data-theme="dark"] {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface-2:  #162032;
  --border:     #334155;
  --text:       #f1f5f9;
  --text-2:     #cbd5e1;
  --text-muted: #94a3b8;
  --shadow:     0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:  0 4px 16px rgba(0,0,0,.4);
  --accent-subtle:  rgba(67,97,238,.18);
  --success-subtle: rgba(22,163,74,.18);
  --danger-subtle:  rgba(220,38,38,.18);
  --warning-subtle: rgba(217,119,6,.18);
  --info-subtle:    rgba(3,105,161,.18);
}

/* ── 3. Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f9fafb;
  letter-spacing: 0.3px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 4px;
  display: none;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #f9fafb;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-company {
  font-size: 0.76rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #f87171;
  text-decoration: none;
  transition: color 0.15s;
}
.btn-logout:hover { color: #fca5a5; text-decoration: none; }
.btn-logout .icon { width: 14px; height: 14px; }

/* ── Main wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content {
  padding: 28px 32px;
  flex: 1;
}

/* ── 4. Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.topbar-user {
  font-size: 0.83rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 0;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
  line-height: 1;
}
.sidebar-toggle-mobile .icon { width: 22px; height: 22px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle .icon { width: 16px; height: 16px; }

/* ── 5. Auth layout ────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 32px 16px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 28px;
}

/* ── 6. Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-header h2 { margin: 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.text-muted   { color: var(--text-muted); }
.text-small   { font-size: 0.82rem; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

/* ── 7. Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.required { color: var(--danger); margin-left: 2px; }

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

[data-theme="dark"] .form-control:focus {
  box-shadow: 0 0 0 3px rgba(67,97,238,.28);
}

.has-error .form-control { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 90px; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='1.5'%3E%3Cpolyline points='6 8 10 12 14 8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 36px;
  appearance: none;
}

[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2394a3b8' stroke-width='1.5'%3E%3Cpolyline points='6 8 10 12 14 8'/%3E%3C/svg%3E");
}

.form-error {
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group-check { display: flex; align-items: center; gap: 8px; }
.form-check-label { font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text); }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 20px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 720px;
}

.form-static-value {
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-control-inline {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ── 8. Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn .icon     { width: 15px; height: 15px; flex-shrink: 0; }
.btn-sm .icon  { width: 13px; height: 13px; }
.btn-lg .icon  { width: 17px; height: 17px; }

.btn:hover     { text-decoration: none; }
.btn:active    { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-primary  { background: var(--accent);   color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-secondary { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.88; }

.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover { opacity: 0.88; }

.btn-warning  { background: var(--warning); color: #fff; }
.btn-info     { background: var(--info);    color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent-subtle); }

[data-theme="dark"] .btn-outline {
  color: #93c5fd;
  border-color: #93c5fd;
}
[data-theme="dark"] .btn-outline:hover {
  background: rgba(147,197,253,.12);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm     { padding: 5px 11px; font-size: 0.8rem; }
.btn-lg     { padding: 11px 26px; font-size: 0.975rem; }
.btn-block  { width: 100%; display: flex; }

/* ── 9. Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead { background: var(--surface-2); }
thead th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 11px 16px;
  vertical-align: middle;
  color: var(--text);
}

td.actions, .table-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { margin-bottom: 14px; font-size: 0.95rem; }

/* ── 10. Cards / Stat Boxes ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-body { padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--accent);
}

.stat-card.green  { border-left-color: var(--success); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.blue   { border-left-color: var(--info); }

.stat-value { font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

/* Price suggestion */
.price-suggestion-box {
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#price-suggestion {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

/* Weekday selector */
.weekday-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.weekday-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}

.weekday-btn input[type="checkbox"] {
  display: none;
}

.weekday-btn:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.weekday-btn:hover {
  border-color: var(--accent);
}

/* ── 11. Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.7;
}

.badge-primary    { background: var(--accent-subtle);  color: var(--accent); }
.badge-secondary  { background: var(--surface-2);      color: var(--text-muted); border: 1px solid var(--border); }
.badge-success,
.badge-green      { background: var(--success-subtle); color: var(--success); }
.badge-danger,
.badge-red        { background: var(--danger-subtle);  color: var(--danger); }
.badge-warning    { background: var(--warning-subtle); color: var(--warning); }
.badge-info       { background: var(--info-subtle);    color: var(--info); }
.badge-dark       { background: var(--text-2);         color: var(--bg); }

[data-theme="dark"] .badge-success,
[data-theme="dark"] .badge-green  { color: #4ade80; }
[data-theme="dark"] .badge-danger,
[data-theme="dark"] .badge-red    { color: #f87171; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-info   { color: #38bdf8; }

/* ── 12. Alerts / Flash messages ───────────────────────────────── */
.flash-container { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid transparent;
  line-height: 1.45;
}

.alert .alert-icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-body { flex: 1; }

.alert-success { background: var(--success-subtle); border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: var(--danger-subtle);  border-color: #fca5a5; color: #991b1b; }
.alert-warning { background: var(--warning-subtle); border-color: #fcd34d; color: #92400e; }
.alert-info    { background: var(--info-subtle);    border-color: #7dd3fc; color: #075985; }

[data-theme="dark"] .alert-success { color: #4ade80; border-color: rgba(74,222,128,.25); }
[data-theme="dark"] .alert-danger  { color: #f87171; border-color: rgba(248,113,113,.25); }
[data-theme="dark"] .alert-warning { color: #fbbf24; border-color: rgba(251,191,36,.25); }
[data-theme="dark"] .alert-info    { color: #38bdf8; border-color: rgba(56,189,248,.25); }

.alert-close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.55; padding: 0; line-height: 1;
  flex-shrink: 0;
  display: flex; align-items: center;
}
.alert-close:hover { opacity: 1; }
.alert-close .icon { width: 16px; height: 16px; }

/* ── 13. Detail display ────────────────────────────────────────── */
.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.detail-section h2 {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.detail-item {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.detail-item:last-child { border-bottom: none; }

dt, .detail-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 3px;
}

dd { font-size: 0.9rem; color: var(--text); margin: 0; }

.price-highlight {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.tree-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.tree-item:last-child { border-bottom: none; }
.tree-children {
  margin-left: 24px;
  border-left: 2px solid var(--border);
  padding-left: 16px;
}

/* ── 14. Service Items ─────────────────────────────────────────── */
.service-items-wrap .edit-only { display: none; }
.service-items-wrap.editing .view-only { display: none !important; }
.service-items-wrap.editing .si-col-days.edit-only  { display: flex; }
.service-items-wrap.editing input.edit-only         { display: block; }
.service-items-wrap.editing label.edit-only         { display: flex; align-items: center; gap: 4px; }
.service-items-wrap.editing .si-actions.edit-only   { display: flex; }

.si-category-block { border-bottom: 2px solid var(--border); }
.si-category-block:last-child { border-bottom: none; }

.si-category-hdr {
  padding: 9px 16px 7px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.si-category-label {
  font-size: 0.77rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
}

.si-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.si-row:last-child { border-bottom: none; }
.si-inactive { opacity: 0.45; }

.si-col-name     { flex: 0 0 190px; font-size: 0.9rem; font-weight: 500; color: var(--text); }
.si-col-days     { flex: 0 0 auto; display: flex; gap: 3px; align-items: center; }
.si-col-interval { flex: 1; min-width: 110px; font-size: 0.875rem; }
.si-col-notes    { flex: 1.5; min-width: 110px; font-size: 0.875rem; }
.si-col-active   { flex: 0 0 auto; white-space: nowrap; font-size: 0.85rem; cursor: pointer; }
.si-col-interval.form-control,
.si-col-notes.form-control { height: 32px; font-size: 0.85rem; padding: 4px 8px; }

.day-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.day-pill.day-on {
  background: var(--info-subtle);
  color: var(--info);
  border-color: transparent;
}
[data-theme="dark"] .day-pill.day-on { color: #38bdf8; }

.day-cb-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  user-select: none;
  color: var(--text);
}
.day-cb-label:hover { background: var(--accent-subtle); }
.day-cb-label input { cursor: pointer; accent-color: var(--accent); }

.si-actions {
  padding: 12px 16px;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.si-add-item-form { display: flex; gap: 8px; align-items: center; }
.si-add-item-row {
  padding: 6px 16px 8px;
  background: var(--surface-2);
  border-top: 1px dashed var(--border);
}

.si-new-category-row {
  padding: 10px 16px;
  background: var(--accent-subtle);
  border-top: 2px dashed var(--accent);
}
.si-new-category-row .si-add-item-form { flex-wrap: wrap; }

.weekday-checks { display: flex; flex-wrap: wrap; gap: 1rem; }

/* ── 15. Icons ─────────────────────────────────────────────────── */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 16. Utilities ─────────────────────────────────────────────── */
.ms-1 { margin-left: 4px; }

/* ── 17. Public pages ──────────────────────────────────────────── */
.public-layout {
  --pub-max: 1100px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

/* Nav */
.pub-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
}
.pub-nav-inner {
  max-width: var(--pub-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 60px;
}
.pub-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.pub-nav-links {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}
.pub-nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.pub-nav-links a:hover { color: var(--text); text-decoration: none; }
.pub-nav-cta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Container */
.pub-container {
  max-width: var(--pub-max);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

/* Hero */
.hero {
  padding: 5rem 1.25rem 4rem;
  text-align: center;
  background: linear-gradient(160deg, var(--bg) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: 99px;
  padding: 0.2rem 0.75rem;
  margin-bottom: 1.25rem;
}
.hero-headline {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--text);
}
.hero-accent { color: var(--accent); }
.hero-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 2rem;
}
.hero-cta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Section headings */
.features-section,
.steps-section,
.directory-teaser,
.cta-banner {
  padding: 4rem 1.25rem;
}
.features-section { background: var(--bg); }
.steps-section    { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.directory-teaser { background: var(--bg); }
.cta-banner       { background: var(--accent); color: #fff; text-align: center; }
.cta-banner h2    { color: #fff; font-size: 1.75rem; margin-bottom: 0.5rem; }
.cta-banner p     { color: rgba(255,255,255,.85); margin-bottom: 1.5rem; }
.cta-banner .btn-primary { background:#fff; color:var(--accent); }
.cta-banner .btn-primary:hover { background:rgba(255,255,255,.9); text-decoration: none; }

.section-title {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text);
}
.section-sub {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 2.5rem;
  font-size: 1rem;
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
}
.feature-card h3 { font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.5rem; color: var(--text); }
.feature-card p  { font-size: 0.9rem; color: var(--text-muted); margin: 0; line-height: 1.6; }
.feature-icon {
  width: 2.5rem; height: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: var(--radius-sm);
}
.feature-icon .icon { width: 1.25rem; height: 1.25rem; }

/* Steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  text-align: center;
}
.step-num {
  width: 3rem; height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.step h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; color: var(--text); }
.step p  { font-size: 0.9rem; color: var(--text-muted); margin: 0; line-height: 1.6; }

/* Company grid */
.company-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.company-grid--full { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.company-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow);
}
.company-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.company-card-city { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.company-card-meta { display: flex; align-items: center; gap: 4px; }
.company-card-meta a,
.company-card-web {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.company-card-meta a:hover,
.company-card-web:hover { text-decoration: underline; }

/* Company card – clickable link variant */
a.company-card--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.company-card--link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  border-color: var(--accent);
}
.company-card-cta {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.company-card-cta .icon { width: 14px; height: 14px; }

/* ── Company profile page ─────────────────────────────── */
.company-profile-page { padding: 2.5rem 1.25rem 5rem; max-width: 960px; margin: 0 auto; }
.profile-breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.profile-breadcrumb a { color: var(--accent); text-decoration: none; }
.profile-breadcrumb a:hover { text-decoration: underline; }

.profile-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
}
.profile-header-inner { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-company-name { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 0 0 0.2rem; }
.profile-company-location { color: var(--text-muted); font-size: 0.9rem; }

.profile-contact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.profile-contact-item {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.875rem; color: var(--text-muted);
}
.profile-contact-item a { color: var(--accent); text-decoration: none; }
.profile-contact-item a:hover { text-decoration: underline; }
.profile-contact-item .icon { width: 14px; height: 14px; }

.profile-body { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
@media (max-width: 720px) { .profile-body { grid-template-columns: 1fr; } }

.profile-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.profile-form-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0 0 0.25rem; }
.profile-form-sub { color: var(--text-muted); font-size: 0.875rem; margin: 0 0 1.5rem; }
.profile-form-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.profile-privacy-note {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.profile-privacy-note a { color: var(--accent); }

.profile-info-col { display: flex; flex-direction: column; gap: 1rem; }
.profile-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.profile-info-card h3 { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.75rem; color: var(--text); }
.profile-info-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.profile-info-list li { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.875rem; color: var(--text-muted); line-height: 1.4; }
.profile-info-list .icon { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.profile-divider { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0; }

/* Directory page */
.directory-page { padding: 3rem 1.25rem 4rem; }
.directory-header { text-align: center; margin-bottom: 2.5rem; }
.directory-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--text); }
.directory-header .section-sub { margin: 0; }

/* Footer */
.pub-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  background: var(--surface);
}
.pub-footer-inner {
  max-width: var(--pub-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.pub-logo-sm {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
}
.pub-footer-links {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}
.pub-footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}
.pub-footer-links a:hover { color: var(--text); }

/* Button sizes + variants for public pages */
.btn-lg { padding: 0.65rem 1.5rem; font-size: 1rem; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
  text-decoration: none;
}

/* Auth back-link */
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.25rem;
}
.auth-back:hover { color: var(--accent); text-decoration: none; }

/* Public responsive */
@media (max-width: 900px) {
  .feature-grid,
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .company-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .pub-nav-links { display: none; }
  .hero { padding: 3.5rem 1rem 2.5rem; }
  .feature-grid,
  .steps-grid,
  .company-grid { grid-template-columns: 1fr; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .pub-footer-links { margin-left: 0; }
}
.ms-2 { margin-left: 8px; }
.me-1 { margin-right: 4px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex   { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.w-100 { width: 100%; }

/* Error pages */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}
.error-code {
  font-size: 5.5rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
}
.error-message {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 1rem 0 2rem;
}

/* ── 17. Responsive ────────────────────────────────────────────── */

/* Tablet / small desktop (≤ 900px) ─ sidebar collapses */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle-mobile { display: block; }
  .content { padding: 18px 16px; }
  .topbar  { padding: 0 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }

  /* Tables: allow horizontal scroll instead of overflowing viewport */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 540px; }

  /* Card headers with many buttons should wrap */
  .card-header { flex-wrap: wrap; gap: 6px; }

  /* Page-header action groups that are too wide should wrap */
  .d-flex.gap-2 { flex-wrap: wrap; }
}

/* Mobile (≤ 640px) ─ single column, stacked layouts */
@media (max-width: 640px) {
  html { font-size: 15px; }

  .content { padding: 14px 12px; }
  .topbar  { padding: 0 12px; gap: 8px; }

  /* Typography */
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }

  /* Page header: stack title + actions */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .page-header .d-flex { flex-wrap: wrap; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; gap: 8px; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }
  .form-card { padding: 18px 14px; }

  /* Auth */
  .auth-card { padding: 22px 16px; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Detail grid: 2 columns on small phones, prevent overflow */
  .detail-grid { grid-template-columns: 1fr 1fr; }

  /* Price suggestion box: stack */
  .price-suggestion-box { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Weekday selector: allow more wrapping */
  .weekday-selector { gap: 5px; }
  .weekday-btn { padding: 4px 10px; font-size: 0.825rem; }

  /* Service item rows: stack vertically on mobile */
  .si-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px;
  }
  .si-col-name     { flex: none; width: 100%; font-size: 0.9rem; }
  .si-col-days     { width: 100%; }
  .si-col-interval { width: 100%; min-width: 0; }
  .si-col-notes    { width: 100%; min-width: 0; }

  /* Service item add forms: stack */
  .si-add-item-form { flex-direction: column; align-items: stretch; }
  .si-add-item-form input[type="text"],
  .si-add-item-form select { width: 100% !important; }
  .si-new-category-row .si-add-item-form { flex-direction: column; }

  /* Tables in cards (assignment table etc) */
  .table-wrapper { border-radius: 0; }

  /* Buttons in table action cells: smaller */
  td.actions .btn { padding: 4px 7px; }
  td.actions .btn .icon { width: 14px; height: 14px; }
}

/* Very small phones (≤ 400px) */
@media (max-width: 400px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: 1fr; }
  .weekday-selector { gap: 4px; }
  .weekday-btn { padding: 4px 7px; font-size: 0.78rem; }
}

/* ── Cookie Consent Banner ─────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--card-bg, #fff);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  padding: 1rem 1.5rem;
  animation: cookieBannerIn 0.3s ease;
}

@keyframes cookieBannerIn {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.cookie-banner-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.cookie-banner-text { flex: 1; min-width: 260px; }

.cookie-banner-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cookie-banner-title .icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.cookie-banner-body {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.cookie-banner-body code {
  font-size: 0.8rem;
  background: var(--accent-subtle);
  color: var(--accent-dark, var(--accent));
  padding: 1px 4px;
  border-radius: 3px;
}

.cookie-banner-link {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 4px;
  font-weight: 500;
}
.cookie-banner-link:hover { text-decoration: underline; }

.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cookie-banner.hide {
  animation: cookieBannerOut 0.25s ease forwards;
}
@keyframes cookieBannerOut {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(100%); opacity: 0; }
}

/* ── Legal / Datenschutz page ──────────────────────────────────── */
.legal-page {
  padding-top: 3rem;
  padding-bottom: 5rem;
  max-width: 860px;
}

.legal-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.legal-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.legal-section {
  margin-bottom: 2.5rem;
}
.legal-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.legal-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.4rem;
}
.legal-section p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.6rem;
}
.legal-section p:last-child { margin-bottom: 0; }

.legal-list {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}
.legal-list li { margin-bottom: 0.25rem; }

.legal-address {
  font-size: 0.9rem;
  font-style: normal;
  color: var(--text-muted);
  line-height: 1.7;
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: block;
}

.legal-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
}
.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.legal-table th,
.legal-table td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.legal-table th {
  background: var(--accent-subtle);
  font-weight: 600;
  color: var(--text);
}
.legal-table td { color: var(--text-muted); }
.legal-table code {
  font-size: 0.82rem;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

@media (max-width: 600px) {
  .cookie-banner-inner { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .cookie-banner-actions { width: 100%; justify-content: flex-end; }
  .legal-title { font-size: 1.5rem; }
}

