:root {
  --red: #C8102E;
  --red-dark: #8B0A1E;
  --black: #0a0a0a;
  --charcoal: #2a2a2a;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --bg: #f4f4f5;
  --card: #fff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --font-main: 'Heebo', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg);
  color: var(--black);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
  min-height: 100vh;
}

.hidden, [hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar, .topbar-inner {
  background-color: var(--black);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  text-decoration: none;
}

.brand__name {
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-badge, .brand__badge {
  background-color: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-actions, .topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background-color: var(--red);
  color: #fff;
}

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

.btn-secondary {
  background-color: transparent;
  color: var(--black);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background-color: var(--bg);
}

.btn-ghost {
  background-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--black);
  background-color: rgba(0,0,0,0.05);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-height: 36px;
}

.btn-login {
  background-color: var(--red);
  color: #fff;
  width: 100%;
  margin-top: 16px;
  min-height: 48px;
}

.btn-login:hover {
  background-color: var(--red-dark);
}

/* Cards & Panels */
.card, .panel {
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

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

.panel-head__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--black);
}

.panel__subtitle {
  font-size: 0.9rem;
  color: var(--muted);
}

.panel__hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.panel__range {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

/* Forms */
.field {
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.field-row .field {
  flex: 1;
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--charcoal);
}

.input, select.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 0.95rem;
  background-color: #fff;
  color: var(--black);
  transition: border-color 0.2s;
  min-height: 44px;
}

.input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.form-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

.form-error.active {
  display: block;
}

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

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  background-color: var(--bg);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.chip-remove {
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  background: none;
  border: none;
  padding: 4px;
}

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

.chips-input {
  border: none;
  padding: 4px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  flex-grow: 1;
  min-width: 120px;
  background: transparent;
}

.chips-input:focus {
  outline: none;
}

/* Grid & Tables */
.grid-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.grid-summary {
  font-size: 0.9rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.table, .grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th, .grid-table th {
  background-color: var(--bg);
  padding: 12px;
  text-align: right;
  font-weight: 600;
  color: var(--charcoal);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td, .grid-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td, .grid-table tr:last-child td {
  border-bottom: none;
}

.grid-row__date {
  font-weight: 700;
  color: var(--black);
  white-space: nowrap;
}

.grid-row__dow {
  color: var(--muted);
  font-size: 0.85rem;
}

.grid-row__day {
  font-weight: 600;
}

.grid-row__cell {
  vertical-align: middle;
}

.grid-row__cell-note {
  font-size: 0.85rem;
  color: var(--muted);
}

.th-actions, .td-actions {
  text-align: center;
  width: 60px;
}

/* Slots & Swatches */
.slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  min-height: 48px;
  width: 100%;
  flex: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
  text-align: center;
}

.slot-available {
  background-color: #e6f4ea;
  color: #1e8e3e;
}

.slot-available:hover {
  background-color: #d4ebda;
}

.slot-maybe {
  background-color: #fef7e0;
  color: #b06000;
}

.slot-maybe:hover {
  background-color: #fdf0c8;
}

.slot-unavailable {
  background-color: #fce8e6;
  color: #c5221f;
}

.slot-unavailable:hover {
  background-color: #f9d8d5;
}

.slot-unset {
  background-color: var(--bg);
  color: var(--muted);
  border: 1px dashed var(--line);
}

.slot-unset:hover {
  border-color: var(--muted);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.swatch-available { background-color: #1e8e3e; }
.swatch-maybe { background-color: #f9ab00; }
.swatch-unavailable { background-color: #c5221f; }
.swatch-unset { background-color: var(--line); }

/* People List */
.people-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.person-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: var(--font-main);
  font-size: 0.95rem;
  gap: 12px;
}

.person-btn:hover {
  border-color: var(--red);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.1);
}

.people-filter {
  margin-bottom: 16px;
}

.people-empty, .others-empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

/* Share View */
.page-share {
  padding: 24px 0;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.share-row:last-child {
  border-bottom: none;
}

.other-person {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.other-person__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.other-person__name {
  font-weight: 700;
  font-size: 1rem;
}

.other-person__meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.other-person__days {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.other-day {
  background-color: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--charcoal);
}

/* Login Page */
.login {
  background-color: var(--black);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background-color: #161616;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  border: 1px solid #2a2a2a;
}

.login-subtitle {
  color: #a0a0a0;
  text-align: center;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.login-error {
  color: var(--red);
  background-color: rgba(200, 16, 46, 0.1);
  padding: 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.login-error.active {
  display: block;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: #666;
}

.login .input {
  background-color: #0a0a0a;
  border-color: #333;
  color: #fff;
}

.login .input:focus {
  border-color: var(--red);
}

.login label {
  color: #ccc;
}

/* Utilities */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg);
  color: var(--charcoal);
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 0.9rem;
}

.day-note {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-sizing: border-box;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--black);
  background-color: #fff;
  transition: border-color 0.2s;
}

.day-note:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

.save-status, #save-status {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.save-status.saving, #save-status.saving {
  color: #b06000;
}

.save-status.saved, #save-status.saved {
  color: #1e8e3e;
}

.save-status.error, #save-status.error {
  color: var(--red);
}

.autosave-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--black);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

.footer {
  margin-top: auto;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer__note {
  margin-top: 8px;
  font-size: 0.75rem;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.rules-body {
  padding: 16px;
  background-color: var(--bg);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--charcoal);
}

/* Admin Matrix */
.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 600px;
}

.matrix-table th {
  background-color: var(--bg);
  padding: 12px;
  text-align: right;
  font-weight: 600;
  color: var(--charcoal);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.matrix-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: center;
}

.matrix-table tr:last-child td {
  border-bottom: none;
}

.matrix-table .slot {
  width: 100%;
  min-width: 80px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }
  
  .field-row .field {
    margin-bottom: 16px;
  }
  
  .grid-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .panel {
    padding: 16px;
  }
  
  .login-card {
    padding: 24px;
  }
  
  .slot {
    font-size: 0.9rem;
    padding: 10px 12px;
  }
  
  .share-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .topbar-inner, .topbar__inner {
    height: 56px;
  }
}
