/* ===== CSS Variables ===== */
:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-dark: #1D4ED8;
  --primary-bg: rgba(37,99,235,0.12);
  --bg: #0a0e1a;
  --surface: rgba(15,23,42,0.7);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-tertiary: #475569;
  --border: rgba(37,99,235,0.15);
  --success: #10B981;
  --success-bg: rgba(16,185,129,0.12);
  --warning: #F59E0B;
  --warning-bg: rgba(245,158,11,0.12);
  --danger: #EF4444;
  --danger-bg: rgba(239,68,68,0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-badge: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  background: #0a0e1a;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; border: none; outline: none; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ===== App Layout ===== */
.app-container {
  max-width: 768px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}
.app-container::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(37,99,235,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139,92,246,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(16,185,129,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.app-container::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(37,99,235,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}
.app-header, .main-content, .bottom-nav {
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: auto;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  border-bottom: 1px solid rgba(37,99,235,0.3);
  display: flex;
  flex-direction: column;
  padding-left: 16px;
  padding-right: 16px;
}

/* Header content row (title + actions) */
.app-header > h1,
.app-header > .header-actions {
  align-self: center;
}

.app-header > .header-actions {
  display: flex;
  gap: 8px;
}
.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}
.header-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding-top: var(--safe-top);
  display: flex;
  gap: 8px;
}
.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
  transition: var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,0.15); }
.header-btn svg { width: 20px; height: 20px; }

/* ===== Main Content ===== */
.main-content {
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  min-height: 100vh;
  transition: padding-top 0.2s ease;
}

/* Extra padding when trial banner is visible */
body.trial-active .main-content {
  padding-top: calc(var(--header-h) + var(--safe-top) + 40px);
}

/* ===== Tab Content ===== */
.tab-content {
  display: none;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}
.tab-content.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #12122a;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-h) + var(--safe-bottom));
}
.bottom-nav .nav-inner {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  height: var(--nav-h);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(255,255,255,0.35);
  transition: var(--transition);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 24px; height: 24px; transition: var(--transition); }
.nav-item span { font-size: 11px; font-weight: 500; }
.nav-item.active { color: #4e79ff; }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: #4e79ff;
  border-radius: 0 0 3px 3px;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ===== Card ===== */
.card {
  background: rgba(15,23,42,0.7);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: var(--radius);
  box-shadow: 0 0 20px rgba(37,99,235,0.05);
  padding: 16px;
  margin-bottom: 12px;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}
.card:hover { box-shadow: 0 0 30px rgba(37,99,235,0.1); border-color: rgba(37,99,235,0.3); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary {
  background: var(--primary-bg);
  color: var(--primary);
}
.btn-secondary:hover { background: rgba(37,99,235,0.2); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-danger:hover { background: #FEE2E2; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); }
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-block { width: 100%; }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15,23,42,0.8);
  border: 1.5px solid rgba(37,99,235,0.2);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: #e2e8f0;
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-input:focus {
  border-color: var(--primary);
  background: rgba(15,23,42,0.95);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-input::placeholder { color: #475569; }
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-badge);
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-rest { background: var(--warning-bg); color: var(--warning); }
.badge-leave { background: var(--danger-bg); color: var(--danger); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 0.2s ease;
}
.modal-overlay.active { display: flex; }
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-content {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 768px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #e2e8f0;
}

.modal-content .form-group label {
  color: #94a3b8;
}

.modal-content .form-input {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #e2e8f0;
}

.modal-content .form-input:focus {
  border-color: #4e79ff;
  background: rgba(255,255,255,0.1);
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: #e2e8f0; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

/* ===== Month Selector ===== */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: var(--shadow);
}
.month-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-bg);
  transition: var(--transition);
  flex-shrink: 0;
}
.month-nav-btn:hover { background: rgba(37,99,235,0.15); }
.month-nav-btn:active { transform: scale(0.93); }
.month-display {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  min-width: 120px;
  text-align: center;
}

/* ===== Calendar Grid ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 8px 8px;
  box-shadow: var(--shadow);
}
.calendar-grid .cal-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 0 6px;
}
.calendar-grid .cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  min-height: 42px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.calendar-grid .cal-day:hover { background: rgba(37,99,235,0.1); }
.calendar-grid .cal-day.active {
  background: var(--primary);
  color: #fff;
}
.calendar-grid .cal-day.other-month {
  opacity: 0.3;
  pointer-events: none;
}
.calendar-grid .cal-day .cal-num {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.calendar-grid .cal-day .cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 3px;
}
.calendar-grid .cal-day.active .cal-dot { background: #fff; }
.calendar-grid .cal-day.today .cal-num { color: var(--primary); font-weight: 800; }
.calendar-grid .cal-day.today.active .cal-num { color: #fff; }

/* ===== Session Cards ===== */
.session-card {
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(37,99,235,0.12);
  border-radius: var(--radius);
  box-shadow: 0 0 15px rgba(37,99,235,0.03);
  margin-bottom: 12px;
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.session-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 10px;
  border-bottom: 1px solid rgba(37,99,235,0.1);
}
.session-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.session-icon.morning { background: rgba(245,158,11,0.15); }
.session-icon.afternoon { background: rgba(37,99,235,0.15); }
.session-icon.evening { background: rgba(139,92,246,0.15); }
.session-info { flex: 1; }
.session-name { font-size: 15px; font-weight: 700; }
.session-count { font-size: 12px; color: var(--text-secondary); }
.session-add-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-bg);
  transition: var(--transition);
}
.session-add-btn:hover { background: rgba(37,99,235,0.15); }
.session-add-btn:active { transform: scale(0.95); }
.session-body { padding: 8px 12px; }
.session-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Schedule Script Groups */
.schedule-script-group {
  padding: 6px 0;
}
.schedule-script-group + .schedule-script-group {
  border-top: 1px solid #E8ECF0;
  margin-top: 4px;
  padding-top: 10px;
}
.schedule-script-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  padding: 4px 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.schedule-script-name::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}
/* 排班列表网格布局 - 剧本卡片等宽 */
.schedule-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.schedule-item--grouped {
  background: rgba(30,41,59,0.4);
  border: 1px solid rgba(71,85,105,0.3);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}
.schedule-item--grouped .schedule-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.schedule-roles-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.schedule-roles-summary .role-tag {
  display: inline-flex;
  align-items: center;
  background: rgba(30,41,59,0.6);
  border: 1px solid rgba(71,85,105,0.4);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  white-space: nowrap;
}
.schedule-roles-summary .role-tag em {
  font-style: normal;
  color: #F87171;
  font-size: 11px;
}
.schedule-delete-group {
  flex-shrink: 0;
  align-self: flex-start;
}
}
.schedule-role-row {
  display: flex;
  align-items: center;
  padding: 5px 0 5px 16px;
  gap: 8px;
}
.schedule-role-name {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 56px;
  flex-shrink: 0;
}
.schedule-role-name::after {
  content: '：';
}
.schedule-actors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.schedule-actor-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.schedule-actor-tag .schedule-delete {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  opacity: 0.5;
  transition: var(--transition);
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.schedule-actor-tag .schedule-delete:hover {
  opacity: 1;
  background: rgba(37,99,235,0.15);
}

/* ===== Smart Recommendation Panel ===== */
/* Daily Overview Card */
.daily-overview {
  margin-top: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(37,99,235,0.08), rgba(37,99,235,0.03));
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: 12px;
}

.daily-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.daily-overview-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.daily-overview-summary {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Recommendation Assignments */
.rec-assignments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 6px;
}

.rec-assignment {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.rec-assignment.free {
  color: var(--success);
}

.rec-assignment.conflict {
  color: var(--warning);
}

.rec-assignment.conflict em {
  font-style: normal;
  font-size: 11px;
  opacity: 0.85;
}

.rec-assignment.uncovered {
  color: var(--danger);
  opacity: 0.7;
}

.recommend-item-tag.insufficient {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.recommend-section {
  margin-top: 16px;
}

.recommend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: rgba(78, 121, 255, 0.08);
  border: 1px solid rgba(78, 121, 255, 0.15);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.recommend-toggle:hover {
  background: rgba(78, 121, 255, 0.12);
}

.recommend-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recommend-toggle-icon {
  font-size: 18px;
}

.recommend-toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.recommend-toggle-badge {
  font-size: 12px;
  color: #4e79ff;
  background: rgba(78, 121, 255, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.recommend-toggle-arrow {
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.recommend-toggle-arrow.open {
  transform: rotate(180deg);
}

.recommend-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recommend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.recommend-item:hover {
  border-color: #4e79ff;
  box-shadow: 0 2px 8px rgba(78, 121, 255, 0.1);
}

.recommend-item-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recommend-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.recommend-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.recommend-item-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.recommend-item-tag.full {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.recommend-item-tag.partial {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.recommend-item-arrow {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.recommend-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ===== Schedule Item - Tag Style ===== */
.schedule-item {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 20px;
  background: rgba(37,99,235,0.12);
  gap: 6px;
  font-size: 13px;
  transition: var(--transition);
  border: 1px solid rgba(37,99,235,0.2);
}
.schedule-item:hover { background: rgba(37,99,235,0.25); }
.schedule-item-info { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.schedule-item--grouped .schedule-item-info { flex-direction: column; align-items: flex-start; }
.schedule-script-row { font-weight: 600; color: #60A5FA; font-size: 13px; }
.schedule-script { font-weight: 600; color: #60A5FA; font-size: 12px; }
.schedule-role { color: #cbd5e1; font-size: 13px; }
.schedule-actor { color: var(--text-secondary); font-size: 12px; }
.schedule-delete {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: var(--transition);
  flex-shrink: 0;
  font-size: 11px;
}
.schedule-delete:hover { background: var(--danger-bg); color: var(--danger); }

/* ===== Dashboard Dark Theme ===== */
#tab-dashboard {
  background: #0f0f23;
  margin: -16px;
  padding: 16px;
  min-height: calc(100vh - var(--header-h) - var(--nav-h) - var(--safe-bottom));
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(37,99,235,0.05);
}
.kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 20px;
}
.kpi-icon.blue { background: rgba(78,121,255,0.15); }
.kpi-icon.green { background: rgba(54,211,153,0.15); }
.kpi-icon.orange { background: rgba(251,146,60,0.15); }
.kpi-icon.red { background: rgba(239,68,68,0.15); }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-value.blue { color: #4e79ff; }
.kpi-value.green { color: #36d399; }
.kpi-value.orange { color: #fb923c; }
.kpi-value.red { color: #ef4444; }
.kpi-label { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 4px; }

/* Chart Cards */
.chart-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}
.chart-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: rgba(255,255,255,0.85);
}
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 350px;
}
.chart-wrapper > div {
  width: 100%;
  height: 100%;
}
.chart-wrapper--pie {
  height: 400px;
}

/* ===== Library Section ===== */
.library-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
}
.library-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.library-tab.active {
  background: var(--primary);
  color: #fff;
}
.library-list { margin-bottom: 16px; }
.library-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.library-item:hover { box-shadow: var(--shadow-md); }
.library-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.library-item-meta { font-size: 12px; color: var(--text-secondary); margin-right: 8px; }
.library-item-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.library-item-delete:hover { background: var(--danger-bg); color: var(--danger); }
.add-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.add-form .form-input { flex: 1; }
.add-form .btn { flex-shrink: 0; }

/* ===== Staff List ===== */
.staff-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(37,99,235,0.12);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: 0 0 15px rgba(37,99,235,0.03);
  gap: 12px;
  backdrop-filter: blur(8px);
}
.staff-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(37,99,235,0.15);
  color: #60A5FA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.staff-info { flex: 1; min-width: 0; }
.staff-name { font-size: 15px; font-weight: 600; }
.staff-stats { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.staff-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-btn {
  padding: 5px 12px;
  border-radius: var(--radius-badge);
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
  border: 1.5px solid transparent;
}
.status-btn.active { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.status-btn.rest { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.status-btn.leave { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.status-btn.disabled-status { background: rgba(100,116,139,0.15); color: #94A3B8; border-color: #64748B; }
.staff-disabled { opacity: 0.5; }
.staff-disabled .staff-avatar { background: rgba(100,116,139,0.15); color: #94A3B8; }
.disabled-tag { font-size: 11px; background: rgba(100,116,139,0.2); color: #94A3B8; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.actor-unavailable { opacity: 0.5; }
.actor-unavailable input[type="checkbox"] { cursor: not-allowed; }
.staff-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.staff-delete:hover { background: var(--danger-bg); color: var(--danger); }
.staff-add-form {
  margin-top: 12px;
  padding: 0 4px;
}

/* ===== Data Actions ===== */
.data-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.data-actions .btn { flex: 1; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-badge);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .modal-content {
    border-radius: 20px;
    margin-bottom: 20vh;
  }
  .modal-overlay {
    align-items: center;
  }
  @keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 1.2rem; }
  .kpi-label { font-size: 0.65rem; }
  .chart-wrapper { height: 260px; }
  .chart-wrapper--pie { height: 380px; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }

.hidden { display: none !important; }

/* ===== Role-Actor Management Styles ===== */
.role-item-expandable {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 4px;
}
.role-item-main {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}
.role-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.role-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.role-assign-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: var(--transition);
}
.role-assign-btn:hover {
  background: var(--primary-bg);
}
.role-actors-display {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-left: 0;
  line-height: 1.4;
}
.actor-count {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== Role-Actor Modal Checklist ===== */
.role-actor-list {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}
.role-actor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
}
.role-actor-row:hover {
  background: var(--bg);
}
.role-actor-row.assigned {
  background: var(--primary-bg);
}
.role-actor-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.role-actor-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}
.role-actor-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.role-actor-status.leave {
  background: var(--danger-bg);
  color: var(--danger);
}
.role-actor-status.rest {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ===== Cascade Select Enhancement ===== */
select.cascade-select {
  transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}
select.cascade-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--bg);
}
select.cascade-select:focus:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Actor Checkbox List (multi-select in schedule modal) */
.actor-select-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}
.actor-checkbox-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--bg);
}
.actor-checkbox-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.actor-checkbox-actions button {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-bg);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.actor-checkbox-actions button:hover {
  background: rgba(37,99,235,0.15);
}
.actor-checkbox-actions button:active {
  transform: scale(0.95);
}
.actor-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}
.actor-checkbox-item:hover {
  background: var(--surface);
}
.actor-checkbox-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.actor-checkbox-item.inactive {
  opacity: 0.6;
}
.actor-checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}
.actor-checkbox-item input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.actor-checkbox-name {
  flex: 1;
  font-weight: 500;
}
.actor-checkbox-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.actor-status-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.actor-status-tag.scheduled {
  background: #FEF3C7;
  color: #92400E;
}
.actor-status-tag.rest {
  background: #E0E7FF;
  color: #4338CA;
}
.actor-status-tag.leave {
  background: #FEE2E2;
  color: #991B1B;
}

/* ===== Mobile optimization for cascade selects ===== */
@media (max-width: 480px) {
  .form-group label {
    font-size: 12px;
    margin-bottom: 4px;
  }
  select.cascade-select {
    font-size: 16px; /* Prevent iOS zoom on focus */
    min-height: 44px;
    padding: 10px 36px 10px 12px;
  }
  .role-actor-row {
    padding: 12px 10px;
    min-height: 44px;
  }
  .role-actor-checkbox {
    width: 22px;
    height: 22px;
  }
}


/* ===== Script Block & Role Card Styles (Dark Theme) ===== */
.script-block {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.script-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.script-block-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.script-block-name {
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
}

.script-block-meta {
  font-size: 12px;
  background: rgba(78,121,255,0.35);
  color: #fff;
  padding: 3px 12px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.script-block-delete {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
  transition: var(--transition);
}
.script-block-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.role-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 12px 14px;
}

.role-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 12px;
  transition: var(--transition);
}
.role-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(78,121,255,0.3);
}

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

.role-card-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.role-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.role-assign-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  color: #fff;
  background: rgba(78,121,255,0.35);
  transition: var(--transition);
  white-space: nowrap;
  font-weight: 600;
}
.role-assign-btn:hover {
  background: rgba(78,121,255,0.55);
}

.role-card-delete {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.25);
  transition: var(--transition);
}
.role-card-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.role-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 26px;
}

.actor-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(78,121,255,0.25);
  color: #c5d5ff;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.2;
}

.actor-chip.unassigned {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.25);
  font-style: italic;
}

.add-role-inline {
  display: flex;
  gap: 6px;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.form-input-sm {
  font-size: 13px !important;
  padding: 6px 10px !important;
  flex: 1;
}

.btn-xs {
  padding: 6px 12px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
}

/* Override library panel background for dark theme in scripts tab */
#tab-library {
  background: #0f0f23;
  margin: -16px;
  padding: 16px;
  min-height: calc(100vh - var(--header-h) - var(--nav-h) - var(--safe-bottom));
}

#tab-library .library-tabs {
  margin-bottom: 14px;
}

#tab-library .library-tab {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.1);
}
#tab-library .library-tab:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
}
#tab-library .library-tab.active {
  background: #3b82f6;
  color: #ffffff;
  font-weight: 700;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

#tab-library .add-form {
  margin-top: 14px;
}

#tab-library .form-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
}

#tab-library .library-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: #e2e8f0;
}
#tab-library .library-item-name {
  color: #e2e8f0;
}
#tab-library .library-item-meta {
  color: rgba(255,255,255,0.4);
}
#tab-library .library-item-delete {
  color: rgba(255,255,255,0.3);
}

#tab-library .empty-state-text {
  color: rgba(255,255,255,0.3);
}

/* Role-Actor Modal dark theme adjustments */
#modal-overlay .role-actor-row {
  color: #e2e8f0;
}
#modal-overlay .role-actor-row.assigned {
  background: rgba(78,121,255,0.15);
}
#modal-overlay .role-actor-row:hover {
  background: rgba(255,255,255,0.08);
}
#modal-overlay .role-actor-name {
  color: #e2e8f0;
}
#modal-overlay .role-actor-status {
  color: rgba(255,255,255,0.5);
}
#modal-overlay .form-input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: #e2e8f0;
}
#modal-overlay select.form-input option {
  background: #1e293b;
  color: #e2e8f0;
}
#modal-overlay .form-input:focus {
  border-color: #4e79ff;
  background: rgba(255,255,255,0.08);
}
#modal-overlay .form-input::placeholder {
  color: rgba(255,255,255,0.3);
}
#modal-overlay .form-group label {
  color: rgba(255,255,255,0.7);
}
#modal-overlay .modal-actions .btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.12);
}
#modal-overlay .modal-actions .btn-secondary:hover {
  background: rgba(255,255,255,0.12);
}

/* Actor checkbox list - dark modal theme */
#modal-overlay .actor-checkbox-list {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}
#modal-overlay .actor-checkbox-item {
  color: #e2e8f0;
}
#modal-overlay .actor-checkbox-item:hover {
  background: rgba(255,255,255,0.08);
}
#modal-overlay .actor-checkbox-name {
  color: #e2e8f0;
}
#modal-overlay .actor-checkbox-item input[type="checkbox"] {
  accent-color: #4e79ff;
}
#modal-overlay .actor-checkbox-actions {
  border-bottom-color: rgba(255,255,255,0.1);
}
#modal-overlay .actor-checkbox-actions button {
  background: rgba(78,121,255,0.15);
  color: #7ba3ff;
}
#modal-overlay .actor-checkbox-actions button:hover {
  background: rgba(78,121,255,0.25);
}
#modal-overlay .actor-checkbox-empty {
  color: rgba(255,255,255,0.4);
}
#modal-overlay .actor-select-hint {
  color: rgba(255,255,255,0.5);
}
#modal-overlay .actor-status-tag.scheduled {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
}
#modal-overlay .actor-status-tag.rest {
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
}
#modal-overlay .actor-status-tag.leave {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}

/* ===== Mobile: Role Cards & Assign Button ===== */
@media (max-width: 480px) {
  .role-cards-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  .role-card {
    padding: 12px 14px;
  }

  .role-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .role-card-name {
    flex: 1;
    min-width: 0;
  }

  .role-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .role-assign-btn {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(78,121,255,0.25);
    border: 1px solid rgba(78,121,255,0.4);
    color: #a0b8ff;
    border-radius: 8px;
  }

  .role-card-delete {
    width: 32px;
    height: 32px;
  }

  .role-card-chips {
    min-height: 28px;
    gap: 5px;
  }

  .actor-chip {
    font-size: 12px;
    padding: 4px 10px;
  }

  .add-role-inline {
    padding: 8px 12px 12px;
  }

  .script-block-header {
    padding: 12px 14px;
  }

  .script-block-name {
    font-size: 15px;
  }
}

/* ===== Trial Banner & Overlay ===== */
/* Trial banner is inside header, displayed at top via order:-1 */
.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(239,68,68,0.1));
  border-bottom: 1px solid rgba(245,158,11,0.2);
  font-size: 13px;
  order: -1; /* Ensure banner is at top of header */
}

.trial-banner[style*="display: none"],
.trial-banner[style*="display:none"] {
  display: none !important;
}

.trial-banner-text {
  color: #fbbf24;
  font-weight: 500;
}

.trial-activate-btn {
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(245,158,11,0.2);
  color: #fbbf24;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(245,158,11,0.3);
  transition: var(--transition);
}
.trial-activate-btn:hover {
  background: rgba(245,158,11,0.3);
}

.trial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
}

.trial-overlay-content {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}

.trial-overlay-icon {
  color: #f59e0b;
  margin-bottom: 16px;
}

.trial-overlay-title {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 8px;
}

.trial-overlay-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 20px;
}

.trial-overlay-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.trial-overlay-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
}
.trial-overlay-input:focus {
  border-color: rgba(78,121,255,0.5);
}

.trial-overlay-submit {
  padding: 10px 20px;
  border-radius: 10px;
  background: #4e79ff;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: var(--transition);
}
.trial-overlay-submit:hover {
  background: #3b68e8;
}

.trial-overlay-hint {
  font-size: 13px;
  color: #ef4444;
  min-height: 20px;
}
.trial-overlay-hint.success {
  color: #36d399;
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
}
.login-form-group {
  margin-bottom: 16px;
}
.login-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.login-form-group input:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
  transition: background var(--transition);
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}
.login-switch a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}
.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }
/* Script roles - like original coze.site */
.script-item { flex-direction: column; gap: 8px; }
.script-main { display: flex; align-items: center; width: 100%; cursor: pointer; gap: 6px; }
.script-compact-roles { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; overflow: hidden; }
.scr-role-tag { display: inline-flex; align-items: center; gap: 2px; background: rgba(74,144,217,0.15); color: #93c5fd; font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.scr-arrow { color: rgba(255,255,255,0.3); margin: 0 2px; }
.scr-role-tag .unassigned { color: rgba(255,255,255,0.3); font-style: italic; }
.script-expand-icon { color: rgba(255,255,255,0.3); font-size: 14px; cursor: pointer; user-select: none; padding: 0 4px; transition: color 0.2s; }
.script-expand-icon:hover { color: rgba(255,255,255,0.7); }
.script-detail { width: 100%; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.06); margin-top: 4px; }
.script-role-list { width: 100%; margin-top: 4px; }
.role-row { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); gap: 8px; }
.role-row:last-child { border-bottom: none; }
.role-name { color: #fff; font-size: 14px; font-weight: 500; min-width: 60px; }
.role-actors { flex: 1; color: #aaa; font-size: 13px; }
.role-actors .unassigned { color: #888; font-style: italic; }
.btn-assign-actor { background: #4a90d9; color: #fff; border: none; border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.btn-assign-actor:hover { background: #357abd; }
.role-delete-btn { background: none; border: none; color: #666; cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; }
.role-delete-btn:hover { color: #e53935; background: rgba(229,57,53,0.1); }
.script-add-role { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.role-input { flex: 1; padding: 6px 10px; border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; font-size: 13px; background: rgba(255,255,255,0.06); color: #fff; outline: none; }
.role-input::placeholder { color: #888; }
.role-input:focus { border-color: #4a90d9; }
.btn-add-role-circle { width: 30px; height: 30px; border-radius: 50%; background: #4a90d9; color: #fff; border: none; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.btn-add-role-circle:hover { background: #357abd; }
/* Assign actor modal */
.assign-actor-list { max-height: 300px; overflow-y: auto; }
.assign-actor-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer; }
.assign-actor-item:last-child { border-bottom: none; }
.assign-actor-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: #4a90d9; }
.assign-actor-item span { color: #e5e7eb; font-size: 14px; }
.actor-status-badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; margin-left: auto; }
.actor-status-badge.active { background: rgba(16,185,129,0.35); color: #34D399; font-weight: 600; }
.actor-status-badge.inactive { background: rgba(251,146,60,0.35); color: #FB923C; font-weight: 600; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ===== Recommendation Panel ===== */
.recommend-section { margin-top: 16px; }
.recommend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(37,99,235,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid rgba(37,99,235,0.2);
  transition: var(--transition);
}
.recommend-toggle:hover { background: rgba(37,99,235,0.15); }
.recommend-toggle-left { display: flex; align-items: center; gap: 8px; }
.recommend-toggle-icon { font-size: 18px; }
.recommend-toggle-title { font-size: 14px; font-weight: 600; color: #e2e8f0; }
.recommend-toggle-badge {
  font-size: 12px;
  color: #60A5FA;
  background: rgba(37,99,235,0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.recommend-toggle-arrow {
  transition: transform 0.3s ease;
  color: #94a3b8;
  display: flex;
}
.recommend-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recommend-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 14px;
}
.recommend-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}
.recommend-item:hover { background: var(--primary-bg); }
.recommend-item-left { flex: 1; min-width: 0; }
.recommend-item-title { font-size: 15px; font-weight: 600; color: var(--text); }
.recommend-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.recommend-item-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.recommend-item-tag.full { background: rgba(16,185,129,0.15); color: #34D399; }
.recommend-item-tag.partial { background: rgba(245,158,11,0.15); color: #FBBF24; }
.recommend-item-tag.insufficient { background: rgba(239,68,68,0.15); color: #F87171; }
.rec-assignments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.rec-assignment {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.rec-assignment.free { background: rgba(16,185,129,0.15); color: #34D399; }
.rec-assignment.conflict { background: rgba(245,158,11,0.15); color: #FBBF24; }
.rec-assignment.conflict em { font-style: normal; color: #D97706; font-size: 11px; }
.rec-assignment.uncovered { background: rgba(239,68,68,0.15); color: #F87171; }
.recommend-item-arrow { color: var(--text-tertiary); flex-shrink: 0; }

/* Search Page */
.search-page {
  padding: 0;
}
.search-bar {
  display: flex;
  align-items: center;
  background: rgba(30,41,59,0.9);
  border: 1.5px solid rgba(37,99,235,0.3);
  border-radius: 12px;
  padding: 0 14px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.search-bar .s-icon {
  width: 18px; height: 18px;
  color: #64748b;
  flex-shrink: 0;
  margin-right: 10px;
}
.search-bar input {
  flex: 1;
  background: none; border: none; outline: none;
  color: #f1f5f9;
  font-size: 16px;
  padding: 12px 0;
  -webkit-appearance: none;
}
.search-bar input::placeholder { color: #475569; }
.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 10px;
  transition: background 0.2s;
}
.search-btn:active { background: #1d4ed8; }

/* Chips */
.search-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.search-chips::-webkit-scrollbar { display: none; }
.sch-chip {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(37,99,235,0.25);
  background: rgba(30,41,59,0.7);
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.sch-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.sch-chip--picker {
  border-style: dashed;
  color: #64748b;
}
.sch-chip--picker.active {
  border-style: solid;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Month picker row */
.search-month-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  animation: fadeIn 0.2s ease;
}
.month-sel {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(37,99,235,0.25);
  background: rgba(30,41,59,0.9);
  color: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
}
.month-sel:focus { border-color: var(--primary); }
.sch-chip--x {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border-color: rgba(239,68,68,0.25);
}
.sch-chip--x:active { background: rgba(239,68,68,0.25); }

/* Results */
.search-hint {
  text-align: center;
  padding: 48px 20px;
  color: #475569;
  font-size: 14px;
}
.search-summary {
  padding: 4px 0 8px;
  font-size: 13px;
  color: #94a3b8;
}
.search-summary b { color: var(--primary); font-weight: 600; }
.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: #475569;
  font-size: 14px;
}
.sdate-card {
  background: rgba(30,41,59,0.7);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid rgba(37,99,235,0.1);
  cursor: pointer;
  transition: border-color 0.15s;
}
.sdate-card:active { border-color: var(--primary); }
.sdate-head {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(37,99,235,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sdate-cnt {
  font-size: 12px;
  font-weight: 400;
  color: #64748b;
  background: rgba(37,99,235,0.1);
  padding: 2px 10px;
  border-radius: 10px;
}
.srow {
  display: flex;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  align-items: center;
  border-bottom: 1px solid rgba(37,99,235,0.05);
}
.srow:last-child { border-bottom: none; }
.srow-period { font-weight: 600; min-width: 36px; color: var(--primary); font-size: 12px; }
.srow-script { flex: 1; color: #e2e8f0; font-weight: 500; }
.srow-role { flex: 1; color: #94a3b8; }
.srow-actor { font-weight: 600; color: var(--accent); }
.srow-actor.hl { color: #fbbf24; text-shadow: 0 0 8px rgba(251,191,36,0.3); }

/* Search Calendar */
.sc-actor-title {
  font-size: 17px; font-weight: 700; color: #fff;
  margin: 20px 0 10px 0; padding: 10px 14px;
  background: linear-gradient(135deg, rgba(37,99,235,0.3), rgba(124,58,237,0.2));
  border-radius: 10px; border-left: 4px solid var(--primary);
}
.sc-actor-cnt { font-size: 13px; color: #93c5fd; font-weight: 500; }
.sc-cal {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 24px;
  background: rgba(15,23,42,0.5); border-radius: 12px; padding: 8px;
}
.sc-cal-hd {
  text-align: center; font-size: 12px; color: #94a3b8;
  padding: 6px 0; font-weight: 700;
}
.sc-cal-cell {
  height: 86px; background: rgba(30,41,59,0.4);
  border-radius: 8px; padding: 3px 4px;
  display: flex; flex-direction: column;
  transition: background 0.15s; overflow: hidden;
}
.sc-cal-empty { background: none; min-height: 0; }
.sc-cal-today { border: 2px solid var(--primary); }
.sc-cal-today .sc-day { color: var(--primary); font-weight: 800; }
.sc-cal-has {
  cursor: pointer;
  background: rgba(37,99,235,0.06);
}
.sc-cal-has:active { background: rgba(37,99,235,0.15); transform: scale(0.97); }
.sc-day { font-size: 12px; color: #cbd5e1; font-weight: 600; margin-bottom: 3px; }
.sc-tag {
  border-radius: 3px; padding: 3px 5px;
  margin: 1px 0 0;
  line-height: 1.2; font-size: 10px; color: #fff; font-weight: 500;
  overflow-wrap: break-word; word-break: break-all;
}



/* Search Select Dropdown */
.search-select { position: relative; }
.ss-input { padding-right: 28px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.ss-dropdown { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 1000; max-height: 200px; overflow-y: auto; background: #1e293b; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; margin-top: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.ss-option { padding: 10px 12px; color: #e2e8f0; font-size: 13px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.04); }
.ss-option:last-child { border-bottom: none; }
.ss-option:hover { background: rgba(37,99,235,0.2); }
.ss-option.ss-disabled { color: #475569; cursor: not-allowed; }
.ss-option.ss-disabled:hover { background: none; }
.ss-empty { padding: 12px; color: #64748b; font-size: 13px; text-align: center; }

/* ===== Leave Modal Custom Styles ===== */
.lv-btn-select, .lv-btn-clear {
  font-size: 12px; padding: 4px 14px; border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; font-weight: 600;
}
.lv-btn-select { background: rgba(37,99,235,0.25); color: #60a5fa; border-color: rgba(37,99,235,0.4); }
.lv-btn-select:hover { background: rgba(37,99,235,0.4); }
.lv-btn-clear { background: rgba(156,163,175,0.2); color: #d1d5db; border-color: rgba(156,163,175,0.3); }
.lv-btn-clear:hover { background: rgba(156,163,175,0.35); }

.lv-badge-active { background: rgba(16,185,129,0.35); color: #34D399; font-weight: 600; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.lv-badge-inactive { background: rgba(251,146,60,0.35); color: #FB923C; font-weight: 600; font-size: 11px; padding: 1px 6px; border-radius: 8px; }

.lv-radio-wrap { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.lv-radio-label { color: #e5e7eb; font-size: 14px; }

.lv-wholeday-wrap { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.lv-wholeday-label { color: #d1d5db; font-size: 12px; }

/* Custom Time Picker */
.tp-wrap { position: relative; display: inline-block; }
.tp-display {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px;
  background: var(--card); color: #e5e7eb; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
  min-width: 90px; justify-content: center;
}
.tp-display:hover { border-color: #4a90d9; }
.tp-wrap.tp-open .tp-display { border-color: #4a90d9; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tp-val { letter-spacing: 1px; }
.tp-dropdown {
  display: none; position: absolute; top: 100%; left: 0; z-index: 1000;
  background: #1a1b2e; border: 1px solid #4a90d9; border-top: none;
  border-radius: 0 0 6px 6px; padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.tp-wrap.tp-open .tp-dropdown { display: flex; gap: 4px; align-items: stretch; }
.tp-col {
  max-height: 160px; overflow-y: auto; flex: 1; min-width: 50px;
  scrollbar-width: thin; scrollbar-color: #4a90d9 transparent;
}
.tp-col::-webkit-scrollbar { width: 4px; }
.tp-col::-webkit-scrollbar-thumb { background: #4a90d9; border-radius: 2px; }
.tp-opt {
  padding: 6px 10px; text-align: center; cursor: pointer; border-radius: 4px;
  color: #d1d5db; font-size: 15px; font-weight: 500; transition: all 0.1s;
}
.tp-opt:hover { background: rgba(37,99,235,0.25); color: #fff; }
.tp-opt.tp-sel { background: #2563eb; color: #fff; font-weight: 700; }
.tp-sep {
  display: flex; align-items: center; justify-content: center;
  color: #9ca3af; font-size: 18px; font-weight: 700; padding: 0 2px;
}

/* Leave Records List */
.lv-date-group { margin-bottom: 12px; }
.lv-date-header { font-size: 12px; color: #9ca3af; font-weight: 600; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 4px; }
.lv-record-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; transition: background 0.15s; }
.lv-record-row:hover { background: rgba(255,255,255,0.04); }
.lv-rec-name { color: #e5e7eb; font-size: 13px; font-weight: 600; min-width: 50px; }
.lv-rec-type { font-size: 11px; padding: 1px 8px; border-radius: 8px; font-weight: 600; }
.lv-rec-time { color: #9ca3af; font-size: 12px; }
.lv-rec-note { color: #6b7280; font-size: 12px; margin-left: auto; }
.lv-rec-del { background: none; border: none; color: #6b7280; cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 4px; margin-left: auto; }
.lv-rec-del:hover { color: #EF4444; background: rgba(239,68,68,0.1); }


/* Leave dot on schedule calendar */
.cal-dot-leave { background: #F97316 !important; }
.cal-day.has-leaves { border-bottom: 2px solid #F9731666; }
/* Day leave bar */
.day-leave-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; margin: 0 0 8px; background: rgba(249,115,22,0.08); border-radius: 8px; border: 1px solid rgba(249,115,22,0.15); }
.dlb-label { font-size: 12px; color: #F97316; font-weight: 600; }
.dlb-tag { font-size: 11px; color: #fb923c; background: rgba(249,115,22,0.12); padding: 2px 8px; border-radius: 10px; font-weight: 500; }

/* Schedule date header & stat badges */
.date-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.date-header h3 { font-size: 15px; font-weight: 600; color: #e5e7eb; margin: 0; }
.date-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stat-badge { font-size: 13px; color: #9ca3af; font-weight: 500; }
.stat-badge.green { color: #34d399; }
.stat-badge.orange { color: #fbbf24; }
