/* Transfer Panel — Apple-inspired minimal UI */

:root {
    --bg: #f5f5f7;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --border: rgba(0, 0, 0, 0.06);
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0, 113, 227, 0.1);
    --success: #34c759;
    --danger: #ff3b30;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.08);
    --blur: blur(20px);
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    min-height: 100vh;
}

/* Login */
.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-backdrop {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 113, 227, 0.12), transparent),
        radial-gradient(ellipse 60% 50% at 80% 90%, rgba(52, 199, 89, 0.08), transparent),
        var(--bg);
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(400px, 100%);
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    animation: cardIn 0.7s var(--ease) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand { text-align: center; margin-bottom: 32px; }

.brand-mark {
    width: 56px; height: 56px;
    margin: 0 auto 16px;
    border-radius: 14px;
    background: linear-gradient(145deg, #0071e3, #40a9ff);
    color: #fff;
    font-size: 28px;
    font-weight: 600;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
}

.brand-mark.sm { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; margin: 0; }

.login-brand h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.login-brand p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }

.field input,
.spreadsheet input,
.spreadsheet select,
.spreadsheet textarea {
    font: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: var(--surface-solid);
    color: var(--text);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    width: 100%;
}

.field input:focus,
.spreadsheet input:focus,
.spreadsheet select:focus,
.spreadsheet textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.login-hint {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 980px;
    padding: 10px 20px;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), background 0.2s var(--ease), opacity 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 113, 227, 0.3);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: rgba(0, 0, 0, 0.03); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; }

.icon-btn {
    width: 36px; height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s var(--ease);
}

.icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.icon-btn svg { width: 20px; height: 20px; }

/* Dashboard layout */
.dashboard-page { min-height: 100vh; }

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s var(--ease);
    text-align: left;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

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

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
}

.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(145deg, #5856d6, #af52de);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-chip strong { display: block; font-size: 0.875rem; }
.user-chip span { font-size: 0.75rem; color: var(--text-secondary); }

.main-content {
    padding: 32px 40px 48px;
    max-width: 1400px;
}

/* Welcome */
.welcome-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 32px;
    animation: fadeUp 0.6s var(--ease) both;
}

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

.welcome-greeting {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.welcome-text h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-top: 4px;
}

.header-actions { display: flex; align-items: center; gap: 16px; }

.save-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.save-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

.save-indicator.saving .dot { background: var(--accent); animation: pulse 1s infinite; }
.save-indicator.saved .dot { background: var(--success); }

.save-indicator .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Calendar */
.calendar-section {
    animation: fadeUp 0.6s 0.1s var(--ease) both;
    transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.calendar-section.collapsed {
    opacity: 0;
    transform: translateY(-20px) scale(0.98);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
}

.calendar-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
}

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

.calendar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.calendar-weekdays span {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
}

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

.cal-day {
    aspect-ratio: 1;
    border: none;
    border-radius: 12px;
    background: transparent;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    cursor: pointer;
    position: relative;
    transition: all 0.25s var(--ease-spring);
    display: grid;
    place-items: center;
}

.cal-day:hover:not(.empty):not(.selected) {
    background: rgba(0, 0, 0, 0.04);
    transform: scale(1.05);
}

.cal-day.empty { cursor: default; }
.cal-day.today { font-weight: 700; color: var(--accent); }
.cal-day.selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 113, 227, 0.35);
}

.cal-day.has-data::after {
    content: '';
    position: absolute;
    bottom: 6px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.cal-day.selected.has-data::after { background: #fff; }

.calendar-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Spreadsheet */
.table-section {
    animation: tableReveal 0.55s var(--ease-spring) both;
}

.table-section[hidden] { display: none !important; }

@keyframes tableReveal {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.table-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.row-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
    padding: 6px 12px;
    border-radius: 980px;
}

.spreadsheet-wrap {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.spreadsheet-scroll {
    overflow-x: auto;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.spreadsheet {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 1100px;
}

.spreadsheet thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fafafa;
}

.spreadsheet th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.spreadsheet td {
    padding: 4px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.spreadsheet tr {
    transition: background 0.15s var(--ease);
}

.spreadsheet tbody tr:hover { background: rgba(0, 113, 227, 0.03); }

.spreadsheet tbody tr.row-new {
    animation: rowPop 0.4s var(--ease-spring) both;
}

@keyframes rowPop {
    from { opacity: 0; transform: scaleY(0.8); background: var(--accent-soft); }
    to { opacity: 1; transform: scaleY(1); background: transparent; }
}

.spreadsheet input,
.spreadsheet select,
.spreadsheet textarea {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    background: transparent;
    min-width: 100px;
}

.spreadsheet input:hover,
.spreadsheet select:hover,
.spreadsheet textarea:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--border);
}

.spreadsheet input:focus,
.spreadsheet select:focus,
.spreadsheet textarea:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.spreadsheet .cell-saving {
    background: rgba(0, 113, 227, 0.06) !important;
}

.spreadsheet .cell-saved {
    animation: cellFlash 0.6s var(--ease);
}

@keyframes cellFlash {
    0% { background: rgba(52, 199, 89, 0.2); }
    100% { background: transparent; }
}

.spreadsheet .cell-hidden {
    color: var(--text-secondary);
    font-style: italic;
    padding: 8px 10px;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 980px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #d4edda; color: #155724; }
.status-completed { background: #e2e3e5; color: #383d41; }
.status-cancelled { background: #f8d7da; color: #721c24; }

.btn-delete-row {
    width: 32px; height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.2s var(--ease);
}

.btn-delete-row:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

/* Permissions */
.permissions-section[hidden] { display: none !important; }

.permissions-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.5s var(--ease) both;
}

.permissions-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.muted { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; }

.perm-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
}

.perm-tab {
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.875rem;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.25s var(--ease);
}

.perm-tab.active {
    background: #fff;
    color: var(--text);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.perm-list { display: flex; flex-direction: column; gap: 8px; }

.perm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: background 0.2s var(--ease);
}

.perm-item:hover { background: rgba(0, 0, 0, 0.02); }

.perm-item span { font-size: 0.9rem; }

/* Toggle switch */
.toggle {
    position: relative;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #e5e5ea;
    border-radius: 980px;
    cursor: pointer;
    transition: background 0.3s var(--ease);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 24px; height: 24px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s var(--ease-spring);
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.nav-icon svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item { position: relative; }
.nav-lock { margin-left: auto; font-size: 0.75rem; opacity: 0.7; }

.panel-view[hidden], .admin-section[hidden] { display: none !important; }

/* Admin panels */
.admin-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 32px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.45s var(--ease) both;
}

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

.admin-card h2 { font-size: 1.25rem; font-weight: 600; }
.muted.sm { font-size: 0.8rem; margin-bottom: 12px; }

.admin-table-wrap { overflow-x: auto; margin-top: 20px; }

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

.admin-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

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

.admin-actions { white-space: nowrap; }
.text-danger { color: var(--danger) !important; }

/* Security panel */
.security-block {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 14px;
}

.security-block-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.badge-owner {
    font-size: 0.7rem;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 980px;
    font-weight: 500;
}

.security-roles { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }

.security-password {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 10px;
}

.sec-pass-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.25s var(--ease);
}

.modal-overlay[hidden] { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--surface-solid);
    border-radius: 20px;
    padding: 28px 32px;
    width: min(400px, 100%);
    box-shadow: var(--shadow-lg);
    animation: cardIn 0.35s var(--ease-spring) both;
}

.modal-wide { width: min(480px, 100%); }

.modal-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
}

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

/* Responsive */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar-nav { flex-direction: row; flex: none; }
    .sidebar-footer { border: none; flex-direction: row; align-items: center; margin-left: auto; }
    .main-content { padding: 20px 16px; }
    .welcome-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}
