/* ============================================================
   Venue Booking — Apple-inspired Design
   ============================================================ */

:root {
  /* SF Pro system font stack */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;

  /* Palette — Apple-inspired light neutrals */
  --bg-page: #f5f5f7;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f2f2f7;
  --bg-hover: #f9f9fb;
  --bg-nav: rgba(255,255,255,0.72);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;
  --accent: #007aff;
  --accent-light: #409cff;
  --accent-bg: rgba(0,122,255,0.07);
  --red: #ff3b30;
  --red-bg: rgba(255,59,48,0.07);
  --green: #34c759;
  --green-bg: rgba(52,199,89,0.07);
  --yellow: #ff9500;
  --yellow-bg: rgba(255,149,0,0.07);
  --blue: #007aff;
  --blue-bg: rgba(0,122,255,0.07);
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.04);
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

/* Dark mode */
[data-theme="dark"] {
  --bg-page: #1c1c1e;
  --bg-white: #2c2c2e;
  --bg-card: #2c2c2e;
  --bg-input: #3a3a3c;
  --bg-hover: #3a3a3c;
  --bg-nav: rgba(44,44,46,0.82);
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #6e6e73;
  --accent: #0a84ff;
  --accent-light: #409cff;
  --accent-bg: rgba(10,132,255,0.15);
  --red: #ff453a;
  --red-bg: rgba(255,69,58,0.15);
  --green: #30d158;
  --green-bg: rgba(48,209,88,0.15);
  --yellow: #ff9f0a;
  --yellow-bg: rgba(255,159,10,0.15);
  --blue: #0a84ff;
  --blue-bg: rgba(10,132,255,0.15);
  --border: #48484a;
  --border-light: #3a3a3c;
  --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.2);
  --shadow: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
}

[data-theme="dark"] .log-viewer {
  background: #000000;
  color: #e5e5ea;
}

[data-theme="dark"] .login-box {
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #48484a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #636366; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* ---- Login ---- */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg-page);
}

.login-box {
  background: var(--bg-white);
  border-radius: 20px;
  padding: 44px 40px 40px;
  width: 360px;
  text-align: center;
  border: 0.5px solid var(--border-light);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent), #5856d6);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.login-box h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-box p {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
  font-weight: 400;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  transition: all var(--transition);
  font-family: var(--font-sans);
  text-align: center;
  letter-spacing: 2px;
}

.login-box input:focus {
  border-color: var(--accent);
  background: var(--bg-white);
  box-shadow: 0 0 0 4px var(--accent-bg);
}

.login-box input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0;
}

.login-box .btn-block {
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 18px;
  font-weight: 500;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  opacity: 0.5;
}

.global-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: #fff;
  font-family: var(--font-sans);
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.97); opacity: 0.85; }

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

.btn-danger { background: var(--red); }
.btn-danger:hover { opacity: 0.85; }

.btn-success { background: var(--green); }
.btn-success:hover { opacity: 0.85; }

.btn-warning { background: var(--yellow); }
.btn-warning:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text-primary); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* ---- Navbar ---- */
.navbar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 32px;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.nav-tabs {
  display: flex;
  gap: 1px;
  list-style: none;
  flex: 1;
}

.nav-tabs li {
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  user-select: none;
}

.nav-tabs li:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
}

.nav-tabs li.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.nav-right { margin-left: auto; }

/* ---- Main Content ---- */
.main {
  padding: 24px;
  max-width: 1480px;
  margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

/* ---- Card Grid ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--accent-bg);
  color: var(--accent);
  letter-spacing: 0.5px;
}

.card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-idle {
  background: var(--bg-input);
  color: var(--text-muted);
}
.badge-idle::before { background: var(--text-muted); }

.badge-running {
  background: var(--green-bg);
  color: var(--green);
}
.badge-running::before { background: var(--green); animation: pulse-dot 2s ease-in-out infinite; }

.badge-finished {
  background: var(--blue-bg);
  color: var(--blue);
}
.badge-finished::before { background: var(--blue); }

.badge-stopped {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.badge-stopped::before { background: var(--yellow); }

.badge-error {
  background: var(--red-bg);
  color: var(--red);
}
.badge-error::before { background: var(--red); }

.badge-free {
  background: var(--green-bg);
  color: var(--green);
}
.badge-free::before { background: var(--green); }

.badge-taken {
  background: var(--red-bg);
  color: var(--red);
}
.badge-taken::before { display: none; }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-bg);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236e6e73'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group { flex: 1; }

/* ---- Time Slot Chips ---- */
.time-checks {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.time-check-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}

.time-check-item:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.time-check-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.time-check-item.checked {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Mode Switch (segmented control) ---- */
.mode-switch {
  display: inline-flex;
  gap: 1px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  padding: 2px;
  margin-bottom: 16px;
}

.mode-switch-btn {
  padding: 6px 18px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
}

.mode-switch-btn:hover { color: var(--text-primary); }

.mode-switch-btn.active {
  background: var(--bg-white);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* ---- Log Viewer ---- */
.log-viewer {
  background: #1c1c1e;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: #e5e5ea;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Slot Grid ---- */
.slot-grid {
  overflow-x: auto;
  margin-top: 16px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border-light);
}

.slot-grid table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.slot-grid th, .slot-grid td {
  border: 0.5px solid var(--border-light);
  padding: 9px 12px;
  text-align: center;
  white-space: nowrap;
}

.slot-grid th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  position: sticky;
  top: 0;
}

.slot-grid td.slot-free {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
}

.slot-grid td.slot-free:hover { background: rgba(52,199,89,0.14); }
.slot-grid td.slot-taken { background: var(--red-bg); color: #ff6961; }
.slot-grid td.slot-closed { background: var(--bg-input); color: var(--text-muted); }
.slot-grid td.slot-mine { background: var(--blue-bg); color: var(--blue); font-weight: 600; }

.slot-grid .court-name {
  text-align: left;
  font-weight: 600;
  background: var(--bg-white);
  color: var(--text-primary);
}

/* ---- Order Table ---- */
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 0.5px solid var(--border-light);
}

.order-table th, .order-table td {
  border-bottom: 0.5px solid var(--border-light);
  padding: 10px 14px;
  text-align: left;
}

.order-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  background: var(--bg-input);
}

.order-table tr:hover td { background: var(--bg-hover); }
.order-table tr:last-child td { border-bottom: none; }

/* ---- Task Panel (Rush / Poll) ---- */
.task-panel {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}

.task-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.task-panel-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

.task-actions { display: flex; gap: 8px; }

/* ---- Poll Task Card ---- */
.poll-task-card .task-panel-header { margin-bottom: 0; }
.poll-task-params { border-bottom: 0.5px solid var(--border-light); padding-bottom: 10px; margin-bottom: 2px; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ---- Animations ---- */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.modal-box {
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  border: 0.5px solid var(--border-light);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
  animation-delay: 0s, var(--toast-duration, 2.7s);
  max-width: 360px;
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-success .toast-icon { background: var(--green-bg); color: var(--green); }
.toast-error .toast-icon { background: var(--red-bg); color: var(--red); }
.toast-info .toast-icon { background: var(--blue-bg); color: var(--blue); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ---- Collapsible Panel ---- */
.panel-collapse-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-input);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}
.panel-collapse-btn:hover { background: var(--border); color: var(--text-primary); }
.panel-collapse-btn svg { transition: transform 0.2s ease; }
.panel-collapse-btn.collapsed svg { transform: rotate(-90deg); }

.panel-body { transition: all 0.25s ease; overflow: hidden; }
.panel-body.collapsed { max-height: 0 !important; padding-top: 0; padding-bottom: 0; opacity: 0; }

/* ---- Log Toolbar ---- */
.log-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 4px;
}

.log-search {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
  max-width: 240px;
}

.log-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.log-search::placeholder { color: var(--text-muted); }

.log-viewer mark {
  background: var(--yellow);
  color: #1c1c1e;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7c7cc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #8e8e93; }
.log-viewer::-webkit-scrollbar-thumb { background: #48484a; }

/* ---- Toggle Switch ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #e9e9eb;
  border-radius: 31px;
  transition: all 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 1px rgba(0,0,0,0.08);
}

.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:disabled + .toggle-slider { opacity: 0.4; cursor: not-allowed; }

/* ---- Launchd Table ---- */
.launchd-table-wrap {
  overflow-x: auto;
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-white);
}

.launchd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.launchd-table th, .launchd-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 0.5px solid var(--border-light);
  vertical-align: middle;
}

.launchd-table th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  position: sticky;
  top: 0;
}

.launchd-table tr:last-child td { border-bottom: none; }
.launchd-table tr:hover td { background: var(--bg-hover); }

/* Drag handle */
.drag-handle {
  cursor: grab;
  text-align: center;
  padding: 0 4px !important;
  width: 28px;
  opacity: 0.35;
  transition: opacity 0.15s;
  user-select: none;
}
.drag-handle:hover { opacity: 0.7; }
.drag-handle:active { cursor: grabbing; }

/* Drag states */
.launchd-table tr.drag-active {
  opacity: 0.4;
}
.launchd-table tr.drag-over-top td {
  box-shadow: inset 0 2px 0 0 var(--accent);
}
.launchd-table tr.drag-over-bottom td {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.launchd-table .form-control { padding: 5px 8px; font-size: 13px; border-width: 0.5px; }

.ld-input-xs { width: 48px !important; text-align: center; }
.ld-input-sm { width: 52px !important; text-align: center; }
.ld-input-md { width: 110px !important; }
.ld-input-date { width: 130px !important; font-size: 12px !important; }
.ld-input-buddy { width: 80px !important; }

.ld-save-msg { font-size: 12px; font-weight: 600; color: var(--green); opacity: 0; transition: opacity 0.3s; }
.ld-save-msg.visible { opacity: 1; }

/* ---- Dashboard Stats ---- */
.dash-stats {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.dash-stat-item {
  flex: 1;
  background: var(--bg-white);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-stat-num {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1.1;
}

.dash-stat-green { color: var(--green); }
.dash-stat-accent { color: var(--accent); }

.dash-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---- Dashboard Cards ---- */
.dash-card {
  position: relative;
  overflow: visible;
}

.dash-avatar {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--accent-bg);
  border-radius: 10px;
  flex-shrink: 0;
}

.dash-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.dash-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.dash-info-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.dash-info-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.dash-card-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 0.5px solid var(--border-light);
}

/* ---- Conflict Banner ---- */
.conflict-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--yellow-bg, rgba(253,203,110,0.12));
  border: 1px solid var(--yellow, #fdcb6e);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}
.conflict-banner svg { color: var(--yellow, #fdcb6e); margin-top: 1px; }

/* ---- Default Account Selector (Dashboard) ---- */
.default-account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.default-account-bar select {
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--bg-white);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}

.default-account-bar .default-account-label {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.default-account-bar .default-account-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: auto;
}

/* ---- Card Dropdown Menu ---- */
.card-menu-wrap { position: relative; }

.card-menu-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: all var(--transition);
  line-height: 1;
}

.card-menu-btn:hover { background: var(--bg-input); color: var(--text-primary); }

.card-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  padding: 4px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.97);
  transition: all 0.15s ease;
}

.card-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.card-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.card-dropdown-item:hover { background: var(--bg-input); color: var(--text-primary); }
.card-dropdown-danger { color: var(--red); }
.card-dropdown-danger:hover { background: var(--red-bg); color: var(--red); }

/* ---- Cancel Mode Tabs ---- */
.cancel-mode-tabs {
  display: inline-flex;
  gap: 1px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  padding: 2px;
}

.cancel-mode-btn {
  padding: 6px 18px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
}

.cancel-mode-btn:hover { color: var(--text-primary); }

.cancel-mode-btn.active {
  background: var(--bg-white);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
  .dash-stats { gap: 10px; }
  .dash-stat-item { padding: 14px 18px; }
}

@media (max-width: 768px) {
  /* ---- Navbar: two-row layout ---- */
  .navbar {
    padding: 8px 12px 0;
    height: auto;
    flex-wrap: wrap;
    gap: 0;
  }

  .navbar .logo { font-size: 15px; margin-right: auto; }

  .nav-right {
    order: 2;
    margin-left: 8px;
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    padding: 8px 0 8px;
    margin: 0;
    flex: none;
  }

  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs li {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ---- Main ---- */
  .main { padding: 14px; }

  /* ---- Section titles ---- */
  .section-title {
    font-size: 18px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .section-title > span { font-size: 11px !important; width: 100%; margin-left: 0 !important; }
  .section-title > div { width: 100%; justify-content: flex-start; }

  /* ---- Dashboard ---- */
  .dash-stats { gap: 8px; flex-wrap: wrap; }
  .dash-stat-item { padding: 12px 14px; min-width: 0; flex: 1 1 45%; }
  .dash-stat-num { font-size: 22px; }
  .card-grid { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 16px; }
  .default-account-bar { flex-wrap: wrap; }
  .default-account-bar .default-account-hint { width: 100%; margin-left: 0; margin-top: 4px; }

  /* ---- Forms ---- */
  .form-row { flex-direction: column; gap: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .form-control { font-size: 16px; } /* prevent iOS zoom */

  /* ---- Rush ---- */
  .task-panel { padding: 14px; }
  .task-panel-header { flex-wrap: wrap; gap: 6px; }
  .task-panel-header .task-panel-title { font-size: 15px; }
  .task-panel-header .task-panel-summary { font-size: 12px; }

  /* ---- Poll ---- */
  .poll-task-card { padding: 14px; }
  .time-checks { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .time-check-item { padding: 6px 8px; font-size: 12px; }

  /* ---- Orders ---- */
  .order-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .order-table th, .order-table td { font-size: 12px; white-space: nowrap; }

  /* ---- Scheduler ---- */
  .launchd-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
  .launchd-table th, .launchd-table td { padding: 8px 6px; font-size: 12px; white-space: nowrap; }
  .launchd-table .ld-input-sm { width: 40px; }
  .launchd-table .ld-input-md { width: 70px; }
  .launchd-table .ld-input-date { width: 100px; font-size: 11px; }

  /* ---- Slots ---- */
  .slot-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .slot-grid table { min-width: 560px; }
  .slot-grid th, .slot-grid td { padding: 6px 8px; font-size: 12px; white-space: nowrap; }

  /* ---- Modals ---- */
  .modal-overlay { padding: 10px; }
  .modal-box { width: 100% !important; max-width: 100%; max-height: 90vh; border-radius: 16px; }

  /* ---- Log viewer ---- */
  .log-viewer { max-height: 200px; font-size: 11px; }
  .log-toolbar { flex-wrap: wrap; gap: 6px; }
  .log-toolbar .log-search { width: 100%; min-width: 0; }

  /* ---- Misc ---- */
  .mode-switch { width: 100%; }
  .mode-switch-btn { flex: 1; text-align: center; padding: 7px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .main { padding: 10px; }
  .section-title { font-size: 16px; }

  /* ---- Navbar ---- */
  .navbar { padding: 6px 10px 0; }
  .navbar .logo { font-size: 14px; }
  .nav-tabs li { padding: 5px 10px; font-size: 12px; }
  .nav-right .btn-sm { padding: 3px 8px; font-size: 11px; }

  /* ---- Dashboard ---- */
  .dash-stats { flex-direction: column; gap: 8px; }
  .dash-stat-item { flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; flex: 1 1 100%; }
  .default-account-bar select { width: 100% !important; min-width: 0 !important; }

  /* ---- Forms & Buttons ---- */
  .btn { padding: 6px 14px; font-size: 12px; }
  .btn-sm { padding: 4px 10px; font-size: 11px; }
  .form-control { font-size: 16px; } /* prevent iOS auto-zoom */

  /* ---- Login ---- */
  .login-box { width: 100%; padding: 36px 24px 32px; border-radius: 16px; }
  .login-icon { width: 56px; height: 56px; border-radius: 14px; }
  .login-box h1 { font-size: 20px; }

  /* ---- Time checks ---- */
  .time-checks { grid-template-columns: repeat(3, 1fr); }
  .time-check-item { padding: 4px 8px; font-size: 11px; }

  /* ---- Toast ---- */
  .toast-container { right: 10px; left: 10px; width: auto; }
  .toast { min-width: auto; max-width: 100%; }
}
