/* Common styles for the shift management system */

/* ==========================================
   Design Tokens
   ========================================== */
:root {
    /* Colors - Primary (Blue) */
    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1e40af;

    /* Colors - Success (Green) */
    --color-success-50: #f0fdf4;
    --color-success-100: #dcfce7;
    --color-success-500: #22c55e;
    --color-success-600: #16a34a;
    --color-success-700: #15803d;

    /* Colors - Warning (Amber) */
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;

    /* Colors - Danger (Red) */
    --color-danger-50: #fef2f2;
    --color-danger-100: #fee2e2;
    --color-danger-500: #ef4444;
    --color-danger-600: #dc2626;

    /* Colors - Neutral (Slate) */
    --color-neutral-50: #f8fafc;
    --color-neutral-100: #f1f5f9;
    --color-neutral-200: #e2e8f0;
    --color-neutral-300: #cbd5e1;
    --color-neutral-400: #94a3b8;
    --color-neutral-500: #64748b;
    --color-neutral-600: #475569;
    --color-neutral-700: #334155;
    --color-neutral-800: #1e293b;
    --color-neutral-900: #0f172a;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-neutral-50);
    min-height: 100vh;
    line-height: 1.6;
    color: var(--color-neutral-900);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--color-neutral-800), var(--color-neutral-700));
    color: white;
    padding: 20px 30px;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.5em;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9em;
}

.app-header .user-info .role-badge {
    background: rgba(255,255,255,0.15);
    padding: 5px 14px;
    border-radius: var(--radius-2xl);
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.15);
}

.app-header .logout-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 7px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
}

.app-header .logout-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.35);
}

/* Main content */
.main-content {
    background: white;
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 32px;
    min-height: 60vh;
}

/* Tabs */
.tab-bar {
    display: flex;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--color-neutral-200);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    background: none;
    color: var(--color-neutral-500);
    font-size: 1em;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    position: relative;
}

.tab-btn .tab-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--color-primary-500);
    background: var(--color-neutral-100);
}

.tab-btn.active {
    color: var(--color-primary-600);
    border-bottom-color: var(--color-primary-500);
    font-weight: 600;
    background: var(--color-primary-50);
}

/* 業務系（シフト構築・メンバー管理）と管理系（シフト期間・設定）のトーン分離 */
.tab-btn.tab-secondary {
    color: var(--color-neutral-400);
    font-size: 0.92em;
}

.tab-btn.tab-secondary:hover {
    color: var(--color-neutral-600);
}

.tab-btn.tab-secondary.active {
    color: var(--color-neutral-700);
    border-bottom-color: var(--color-neutral-500);
    background: var(--color-neutral-100);
}

/* 業務系と管理系の境界線 */
.tab-separator {
    display: inline-block;
    width: 1px;
    background: var(--color-neutral-200);
    margin: 6px 8px;
    align-self: stretch;
}

/* タブ内バッジ */
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--color-primary-500);
    color: #fff;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
}

.tab-btn.tab-secondary .tab-badge {
    background: var(--color-neutral-400);
}

.tab-badge[hidden] {
    display: none;
}

.tab-badge.tab-badge-dot {
    min-width: 8px;
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    background: var(--color-danger-500, #dc2626);
}

.tab-content {
    display: none;
}

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

/* Cards */
.card {
    background: var(--color-neutral-100);
    padding: 24px;
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--color-primary-500);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.card h3 {
    color: var(--color-primary-700);
    margin-bottom: 16px;
    font-size: 1.15em;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-neutral-700);
    font-size: 0.9em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-neutral-200);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: white;
    color: var(--color-neutral-900);
    transition: all 0.2s ease;
}

.form-control:hover {
    border-color: var(--color-neutral-300);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

/* ==========================================
   Buttons (5 semantic categories — see docs/notes/260509_button_audit.md)
   ==========================================
   primary         : 画面の主目的アクション (青塗り、強)
   secondary       : 編集・取得などのサブアクション (グレー枠、中性)
   state-warning   : 取り消し可能な状態変更（要注意） (オレンジ枠、中)
   state-positive  : 取り消し可能な復帰系 (緑枠、中)
   destructive     : 取り消し不可 (赤塗り、強)
   ========================================== */

/* Base */
.btn {
    padding: 10px 24px;
    border: 1.5px solid transparent;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    color: inherit;
}

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

.btn:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Sizes */
.btn-xs {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: var(--radius-md);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
    border-radius: var(--radius-lg);
}

/* === primary === */
.btn-primary {
    background: var(--color-primary-500);
    border-color: var(--color-primary-500);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-600);
    border-color: var(--color-primary-600);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* === secondary === */
.btn-secondary {
    background: white;
    border-color: var(--color-neutral-300);
    color: var(--color-neutral-700);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--color-neutral-50);
    border-color: var(--color-neutral-400);
    color: var(--color-neutral-800);
}

/* === state-warning === */
.btn-state-warning {
    background: white;
    border-color: var(--color-warning-500);
    color: var(--color-warning-600);
}
.btn-state-warning:hover:not(:disabled) {
    background: var(--color-warning-50);
    border-color: var(--color-warning-600);
    color: var(--color-warning-600);
}

/* === state-positive === */
.btn-state-positive {
    background: white;
    border-color: var(--color-success-500);
    color: var(--color-success-600);
}
.btn-state-positive:hover:not(:disabled) {
    background: var(--color-success-50);
    border-color: var(--color-success-600);
    color: var(--color-success-700);
}

/* === destructive === */
.btn-destructive {
    background: var(--color-danger-500);
    border-color: var(--color-danger-500);
    color: white;
}
.btn-destructive:hover:not(:disabled) {
    background: var(--color-danger-600);
    border-color: var(--color-danger-600);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-neutral-200);
}

.data-table th {
    background: var(--color-neutral-100);
    font-weight: 600;
    color: var(--color-neutral-600);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table tr:hover {
    background: var(--color-neutral-50);
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge-draft { background: var(--color-neutral-200); color: var(--color-neutral-600); }
.badge-open { background: var(--color-primary-50); color: var(--color-primary-700); }
.badge-closed { background: var(--color-warning-50); color: var(--color-warning-600); }
.badge-finalized { background: var(--color-success-50); color: var(--color-success-600); }
.badge-submitted { background: var(--color-primary-50); color: var(--color-primary-700); }
.badge-pending { background: var(--color-warning-50); color: var(--color-warning-600); }
.badge-approved { background: var(--color-success-50); color: var(--color-success-600); }
.badge-rejected { background: var(--color-danger-50); color: var(--color-danger-600); }
.badge-confirmed { background: var(--color-success-50); color: var(--color-success-700); }
.badge-calendar { background: var(--color-primary-50); color: var(--color-primary-700); }
.badge-manual { background: var(--color-neutral-200); color: var(--color-neutral-600); }

/* Calendar grid */
.month-container {
    margin-bottom: 24px;
}

.month-title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--color-neutral-800);
    margin-bottom: 12px;
    padding-left: 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.calendar-header {
    text-align: center;
    font-weight: 600;
    color: var(--color-neutral-500);
    padding: 8px 4px;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.calendar-day {
    min-height: 80px;
    padding: 8px;
    border: 1.5px solid var(--color-neutral-200);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.85em;
    position: relative;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.calendar-day:not(.empty):hover {
    box-shadow: var(--shadow-sm);
}

.calendar-day.empty {
    border: none;
    background: transparent;
}

.calendar-day .day-number {
    font-weight: 700;
    font-size: 0.95em;
    color: var(--color-neutral-800);
    margin-bottom: 6px;
}

.calendar-day .time-slot {
    font-size: 0.78em;
    color: var(--color-neutral-500);
    line-height: 1.4;
}

.calendar-day.available {
    background: var(--color-success-50);
    border-color: var(--color-success-100);
}

.calendar-day.partial {
    background: var(--color-warning-50);
    border-color: var(--color-warning-100);
}

.calendar-day.unavailable {
    background: var(--color-danger-50);
    border-color: var(--color-danger-100);
}

.calendar-day.excluded {
    background: var(--color-neutral-100);
    border-color: var(--color-neutral-200);
    opacity: 0.6;
}

.calendar-day.calendar-disabled {
    opacity: 0.4;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-neutral-500);
}

.loading p {
    margin-top: 12px;
    font-size: 0.9em;
}

.loading-spinner {
    display: inline-block;
    width: 44px;
    height: 44px;
    border: 3px solid var(--color-neutral-200);
    border-top-color: var(--color-primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes highlightFadeIn {
    from { background-color: var(--color-primary-100); }
    to { background-color: transparent; }
}

.exception-row-new {
    animation: highlightFadeIn 2s ease-out;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--color-neutral-400);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--color-neutral-300);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 1em;
    margin-bottom: 8px;
    color: var(--color-neutral-500);
}

.empty-state .empty-state-hint {
    font-size: 0.85em;
    color: var(--color-neutral-400);
}

/* Guidance / Help text components */
.guide-box {
    background: var(--color-primary-50);
    border: 1px solid var(--color-primary-100);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 0.9em;
    line-height: 1.7;
    color: var(--color-neutral-700);
}

.guide-box-title {
    font-weight: 600;
    color: var(--color-primary-700);
    margin-bottom: 6px;
    font-size: 0.95em;
}

.guide-steps {
    list-style: none;
    counter-reset: guide-step;
    padding: 0;
    margin: 0;
}

.guide-steps li {
    counter-increment: guide-step;
    padding: 4px 0 4px 32px;
    position: relative;
}

.guide-steps li::before {
    content: counter(guide-step);
    position: absolute;
    left: 0;
    top: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary-500);
    color: white;
    font-size: 0.75em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-text {
    font-size: 0.85em;
    color: var(--color-neutral-500);
    line-height: 1.6;
    margin-top: 4px;
}

.field-hint {
    font-size: 0.82em;
    color: var(--color-neutral-400);
    margin-top: 4px;
}

/* Confirm dialog */
.confirm-dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.confirm-dialog {
    background: white;
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: confirmIn 0.15s ease-out;
}

@keyframes confirmIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.confirm-dialog h3 {
    margin-bottom: 12px;
    font-size: 1.1em;
    color: var(--color-neutral-800);
}

.confirm-dialog p {
    color: var(--color-neutral-600);
    font-size: 0.92em;
    line-height: 1.6;
    margin-bottom: 20px;
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Modal/Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal h3 {
    margin-bottom: 16px;
    color: var(--color-neutral-800);
    font-size: 1.15em;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ==========================================
   Day Popup (shared between worker & admin)
   ========================================== */

.day-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

.day-popup-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.day-popup {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
}

.day-popup.visible {
    transform: scale(1) translateY(0);
}

.day-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--color-neutral-100);
}

.day-popup-date {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--color-neutral-800);
}

.day-popup-close {
    background: none;
    border: none;
    font-size: 1.3em;
    color: var(--color-neutral-400);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-md);
    line-height: 1;
    transition: all 0.15s;
}

.day-popup-close:hover {
    background: var(--color-neutral-100);
    color: var(--color-neutral-700);
}

.day-popup-section {
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-neutral-100);
}

.day-popup-section:last-child {
    border-bottom: none;
    padding-bottom: 20px;
}

.day-popup-label {
    font-size: 0.78em;
    font-weight: 600;
    color: var(--color-neutral-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.day-popup-opening-hours {
    font-size: 1em;
    color: var(--color-neutral-800);
    font-weight: 500;
}

/* Toggle switch */
.day-popup-toggle-row {
    display: flex;
    align-items: center;
}

.day-popup-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 0;
}

.toggle-track {
    display: inline-block;
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: var(--color-neutral-300);
    position: relative;
    transition: background 0.2s;
}

.day-popup-toggle.active .toggle-track {
    background: var(--color-primary-500);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.day-popup-toggle.active .toggle-thumb {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--color-neutral-500);
}

.day-popup-toggle.active .toggle-label {
    color: var(--color-primary-600);
}

/* Time editing in popup */
.day-popup-time-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.popup-time-input {
    width: auto !important;
    flex: 1;
    padding: 8px 10px !important;
    font-size: 1em !important;
}

.time-separator {
    color: var(--color-neutral-400);
    font-size: 0.95em;
    flex-shrink: 0;
}

.day-popup-time-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* Timeline bar */
.timeline-bar {
    position: relative;
    height: 28px;
    background: var(--color-neutral-100);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tl-block {
    position: absolute;
    top: 0;
    height: 100%;
    min-width: 1px;
}

.timeline-labels {
    position: relative;
    height: 18px;
    margin-top: 2px;
    font-size: 0.7em;
    color: var(--color-neutral-400);
}

.tl-label {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    font-size: 0.75em;
    color: var(--color-neutral-500);
}

.tl-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.tl-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Grid layout helpers */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* Flex helpers */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ==========================================
   Button Loading & Feedback States
   ========================================== */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-secondary.btn-loading::after,
.btn-state-warning.btn-loading::after,
.btn-state-positive.btn-loading::after,
.btn-loading.btn-loading-dark::after {
    border-color: rgba(0,0,0,0.15);
    border-top-color: var(--color-primary-500);
}

.btn-copied {
    background: var(--color-success-500) !important;
    border-color: var(--color-success-500) !important;
    color: white !important;
    transition: all 0.2s;
}

/* Inline spinner (next to text) */
.spinner-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-neutral-200);
    border-top-color: var(--color-primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* Invite status badges */
.badge-invite-pending { background: var(--color-primary-50); color: var(--color-primary-700); }
.badge-invite-accepted { background: var(--color-success-50); color: var(--color-success-700); }
.badge-invite-expired { background: var(--color-neutral-200); color: var(--color-neutral-500); }

/* Fade-in animation */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Success icon with scale animation */
.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-success-50);
    color: var(--color-success-500);
    animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Error box */
.error-box {
    background: var(--color-danger-50);
    border: 1px solid var(--color-danger-100, #fecaca);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.error-box-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--color-danger-600);
    margin-bottom: 8px;
}

.error-box-message {
    color: var(--color-neutral-600);
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 16px;
}

.error-box .btn {
    margin-top: 4px;
}

/* Responsive */
/* ==========================================
   Event Chips (shared between worker & admin popups)
   ========================================== */

.day-popup-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.day-popup-no-events {
    color: var(--color-neutral-300);
    font-size: 0.9em;
    padding: 8px 0;
}

.event-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: var(--color-neutral-50);
    border-left: 3px solid var(--color-primary-600);
    font-size: 0.9em;
}

.event-chip-allday {
    border-left-color: var(--color-success-500);
    background: var(--color-success-50);
}

.event-chip-timed {
    border-left-color: var(--color-primary-600);
    background: var(--color-primary-50);
}

.event-chip-time {
    font-weight: 700;
    color: var(--color-neutral-800);
    white-space: nowrap;
    font-size: 0.85em;
    min-width: 80px;
}

.event-chip-allday .event-chip-time {
    color: var(--color-success-600);
}

.event-chip-timed .event-chip-time {
    color: var(--color-primary-700);
}

.event-chip-title {
    color: var(--color-neutral-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Sync status bar */
.sync-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--color-neutral-50);
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-md);
    font-size: 0.88em;
    color: var(--color-neutral-600);
}

.sync-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-neutral-200);
    flex-shrink: 0;
}

.sync-status-icon.synced {
    background: var(--color-success-100);
    color: var(--color-success-600);
}

.sync-status-icon.not-synced {
    background: var(--color-neutral-200);
    color: var(--color-neutral-400);
}

.sync-status-text {
    flex: 1;
    line-height: 1.4;
}

.sync-status-link {
    color: var(--color-primary-500);
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    background: none;
    text-decoration: underline;
    white-space: nowrap;
    padding: 0;
}

.sync-status-link:hover {
    color: var(--color-primary-700);
}

/* Sync log table */
.sync-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.sync-log-table th,
.sync-log-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-neutral-200);
}

.sync-log-table th {
    background: var(--color-neutral-100);
    font-weight: 600;
    color: var(--color-neutral-500);
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sync-log-table tr:hover {
    background: var(--color-neutral-50);
}

/* Settings collapse (details/summary) */
.settings-collapse {
    margin-top: 8px;
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-lg);
    background: var(--color-neutral-50);
}

.settings-collapse > summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--color-neutral-600);
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    user-select: none;
    transition: color 0.15s;
}

.settings-collapse > summary::-webkit-details-marker {
    display: none;
}

.settings-collapse > summary::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--color-neutral-400);
    border-bottom: 2px solid var(--color-neutral-400);
    transform: rotate(-45deg);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.settings-collapse[open] > summary::before {
    transform: rotate(45deg);
}

.settings-collapse > summary:hover {
    color: var(--color-primary-600);
}

.settings-collapse-body {
    padding: 8px 20px 20px;
}

/* Import Preview Calendar */
.preview-month-title {
    font-size: 1em;
    font-weight: 600;
    color: var(--color-neutral-700);
    margin-bottom: 8px;
    padding-left: 2px;
}

.preview-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 16px;
}

.preview-calendar-header {
    text-align: center;
    font-weight: 600;
    color: var(--color-neutral-500);
    padding: 4px;
    font-size: 0.78em;
    letter-spacing: 0.3px;
}

.preview-calendar-cell {
    min-height: 52px;
    padding: 5px;
    border-radius: var(--radius-sm);
    background: white;
    border: 1.5px solid var(--color-neutral-200);
    font-size: 0.8em;
}

.preview-calendar-cell.empty {
    border: none;
    background: transparent;
    min-height: 0;
}

.preview-calendar-cell.preview-clickable {
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.preview-calendar-cell.preview-clickable:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary-500);
}

.preview-calendar-cell.out-of-range {
    opacity: 0.25;
}

.preview-calendar-cell.preview-calendar-source {
    background: var(--color-primary-50);
    border-color: var(--color-primary-500);
}

.preview-calendar-cell.preview-manual-source {
    background: var(--color-success-50);
    border-color: var(--color-success-500);
}

.preview-calendar-cell.preview-closed {
    background: var(--color-neutral-100);
    border-color: var(--color-neutral-300);
}

.preview-calendar-cell.preview-default {
    background: white;
    border-color: var(--color-neutral-200);
}

.preview-day-num {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--color-neutral-800);
}

.preview-day-time {
    font-size: 0.72em;
    color: var(--color-neutral-500);
    margin-top: 2px;
    line-height: 1.3;
}

.preview-calendar-cell.preview-calendar-source .preview-day-time {
    color: var(--color-primary-700);
}

.preview-calendar-cell.preview-manual-source .preview-day-time {
    color: var(--color-success-700);
}

.preview-calendar-cell.preview-closed .preview-day-time {
    color: var(--color-neutral-400);
}

.preview-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.78em;
    color: var(--color-neutral-500);
    padding-top: 4px;
}

.preview-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.preview-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1.5px solid transparent;
    flex-shrink: 0;
}

.preview-legend-dot.preview-calendar-source {
    background: var(--color-primary-50);
    border-color: var(--color-primary-500);
}

.preview-legend-dot.preview-manual-source {
    background: var(--color-success-50);
    border-color: var(--color-success-500);
}

.preview-legend-dot.preview-closed {
    background: var(--color-neutral-100);
    border-color: var(--color-neutral-300);
}

.preview-legend-dot.preview-default {
    background: white;
    border-color: var(--color-neutral-200);
}

@media (max-width: 768px) {
    .app-container { padding: 10px; }
    .app-header {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        text-align: center;
    }
    .app-header h1 { font-size: 1.2em; }
    .app-header .user-info { justify-content: center; flex-wrap: wrap; }
    .main-content { padding: 24px 16px; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .calendar-day { min-height: 64px; padding: 6px; }
    .tab-btn { padding: 8px 12px; font-size: 0.88em; gap: 5px; }
    .tab-btn .tab-icon { width: 14px; height: 14px; }
    .tab-btn.tab-secondary { font-size: 0.82em; }
    .tab-separator { margin: 4px 4px; }
    .form-group { margin-bottom: 20px; }
    .btn { width: 100%; justify-content: center; }
    .modal-actions .btn { width: auto; }
    .confirm-dialog-actions .btn { width: auto; }

    /* Day popup → bottom sheet on mobile */
    .day-popup-overlay {
        align-items: flex-end;
    }
    .day-popup {
        max-width: 100%;
        width: 100%;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        max-height: 80vh;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .day-popup.visible {
        transform: translateY(0);
    }
    .day-popup-header {
        padding: 16px 20px 12px;
    }
    .day-popup-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 5px;
        background: var(--color-neutral-300);
        border-radius: 3px;
        margin: 0 auto 12px;
    }
    .day-popup-section {
        padding: 14px 20px;
    }
}
