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

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --success: #34c759;
    --danger: #ff3b30;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #888;
    --border: #e0e0e0;
    --rest-bg: #f0f0f0;
    --rest-text: #999;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius: 10px;
    --font-size: 15px;
    --font-size-sm: 13px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--font-size);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.nav-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-copy {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: background 0.15s;
    min-width: 80px;
    text-align: center;
}

.btn-copy:active {
    background: rgba(255, 255, 255, 0.35);
}

.btn-copy:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}

.btn-logout:active {
    background: rgba(255, 255, 255, 0.3);
}

/* User Bar */
.user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.user-select-wrapper {
    flex: 1;
    position: relative;
}

.user-select {
    width: 100%;
    padding: 10px 30px 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size);
    background: var(--bg);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    min-height: 44px;
}

.select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
    font-size: 11px;
}

.btn-add-user {
    padding: 10px 16px;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: var(--font-size);
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    min-width: 70px;
}

.btn-add-user:active {
    background: var(--primary-dark);
}

/* Week Bar */
.week-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.btn-week-nav {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.btn-week-nav:active {
    background: #e0e0e0;
}

.btn-week-nav:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.week-range {
    font-size: 16px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

.btn-config {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: var(--font-size);
    cursor: pointer;
    margin-left: 4px;
    min-height: 44px;
    min-width: 56px;
}

.btn-config:active {
    background: var(--primary-dark);
}

.btn-config:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Shifts List */
.shifts-list {
    padding: 10px 16px;
}

.shift-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    margin-bottom: 6px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    min-height: 48px;
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
}

.shift-row:active {
    transform: scale(0.98);
    background: #f0f5ff;
}

.shift-row-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shift-label {
    font-weight: 600;
    font-size: var(--font-size);
    min-width: 36px;
}

.shift-date {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.shift-row-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shift-time-badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.shift-placeholder {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.shift-rest {
    color: var(--rest-text);
    font-style: italic;
    font-size: var(--font-size);
}

.shift-arrow {
    color: #ccc;
    font-size: 18px;
}

/* Row States */
.row-rest {
    background: var(--rest-bg);
    pointer-events: none;
    opacity: 0.7;
}

.row-rest:active {
    transform: none;
    background: var(--rest-bg);
}

.row-empty {
    border: 1px dashed var(--border);
}

/* Empty State */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: var(--font-size);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: 14px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
}

.modal-close:active {
    background: #eee;
}

.modal-body {
    padding: 18px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 0 18px 18px;
}

/* Buttons */
.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-size: var(--font-size);
    cursor: pointer;
    min-height: 44px;
    font-weight: 500;
}

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

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:active {
    background: #e0e0e0;
}

/* Input */
.input-text {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size);
    outline: none;
    min-height: 44px;
}

.input-text:focus {
    border-color: var(--primary);
}

/* Fullscreen Panel */
.fullscreen-panel {
    position: fixed;
    inset: 0;
    background: var(--card-bg);
    z-index: 300;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 17px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    min-height: 52px;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.panel-footer {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

/* Week Selector */
.week-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    margin: 4px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    min-height: 56px;
    border: 1.5px solid transparent;
    transition: background 0.15s;
}

.week-option:active {
    background: var(--bg);
}

.week-option-selected {
    background: #e8f0fe;
    border-color: var(--primary);
}

.week-option-date {
    font-weight: 600;
    font-size: 16px;
}

.week-option-relative {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Bottom Sheet */
.bottomsheet-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
}

.bottomsheet {
    background: var(--card-bg);
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
}

.sheet-body {
    padding: 16px 18px 24px;
}

.quick-times-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.quick-times-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.btn-quick-time {
    padding: 14px 6px;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--primary);
    font-size: var(--font-size);
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.1s;
}

.btn-quick-time:active {
    background: var(--primary);
    color: #fff;
}

.btn-custom {
    border-style: dashed;
    color: var(--text-secondary);
    font-weight: 500;
    border-color: var(--border);
}

/* Custom Time Section */
.custom-time-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.time-selector-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.time-selector-row label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    min-width: 70px;
}

.time-select {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size);
    background: var(--card-bg);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    min-height: 44px;
}

.btn-confirm-custom {
    width: 100%;
    margin-top: 6px;
}

/* Current Time Display */
.current-time-display {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
}

.ctd-row {
    padding: 6px 0;
    font-size: var(--font-size);
    display: flex;
    justify-content: space-between;
}

.ctd-row strong {
    color: var(--primary);
    font-size: 16px;
}

/* Clear Button */
.btn-clear {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--danger);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--danger);
    font-size: var(--font-size);
    cursor: pointer;
    min-height: 44px;
}

.btn-clear:active {
    background: #fff0f0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 24px;
    font-size: var(--font-size-sm);
    color: #fff;
    z-index: 400;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Transitions */
.sheet-enter {
    transition: transform 0.25s ease-out;
}

.sheet-leave {
    transition: transform 0.2s ease-in;
}

[x-cloak] {
    display: none !important;
}

/* Login Page Styles */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef4fc 0%, #dbe8f8 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.login-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 32px 24px;
    box-shadow: 0 10px 30px rgba(74, 144, 217, 0.15);
    border: 1px solid rgba(74, 144, 217, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 26px;
}

.login-icon {
    font-size: 42px;
    line-height: 1;
    margin-bottom: 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.login-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

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

.password-input-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

.password-input {
    width: 100%;
    padding: 13px 44px 13px 14px;
    font-size: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg);
}

.password-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.18);
}

.btn-toggle-pwd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-toggle-pwd:active {
    background: rgba(0, 0, 0, 0.05);
}

.login-error {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid #ffd2d2;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: var(--font-size-sm);
    margin-bottom: 16px;
    text-align: center;
}

.btn-login {
    width: 100%;
    padding: 13px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
}

.login-tip {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tip-icon {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
