/* ── Theme variables ── */
:root {
    --bg: #f4f7fe;
    --card: #ffffff;
    --text: #2d3436;
    --border: #e2e8f0;
    --input: #f8f9fa;
    --shadow: rgba(0,0,0,0.06);
    --taken: linear-gradient(90deg,#eef2ff 0%,#ffffff 100%);
    --cancelled: linear-gradient(90deg,#ffe0e0 0%,#ffffff 100%);
    --login-card: #ffffff;
    --glow: rgba(79,124,255,0.14);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.dark-mode {
    --bg: #0b0b10;
    --card: #1c1c28;
    --text: #ffffff;
    --border: #2a2a36;
    --input: #252533;
    --shadow: rgba(0,0,0,0.5);
    --taken: linear-gradient(90deg,#1e2a3a 0%,#161620 100%);
    --cancelled: linear-gradient(90deg,#3d1a1a 0%,#1c1c28 100%);
    --login-card: #1c1c28;
    --glow: rgba(79,124,255,0.09);
}

/* ── Animations ── */
@keyframes popIn { from { opacity:0; transform:scale(0.92) translateY(12px) } to { opacity:1; transform:scale(1) translateY(0) } }
@keyframes slideUp { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:translateY(0) } }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
@keyframes slideInLeft { from { opacity:0; transform:translateX(8px) } to { opacity:1; transform:translateX(0) } }
@keyframes checkPop { 0% { transform:scale(0) } 50% { transform:scale(1.2) } 100% { transform:scale(1) } }

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* ── Custom Checkboxes ── */
input[type="checkbox"] {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    width: 22px; height: 22px; min-width: 22px;
    border: 2px solid var(--border); border-radius: 6px;
    background: var(--input); cursor: pointer; position: relative;
    transition: all 0.2s; margin: 0; flex-shrink: 0;
}
input[type="checkbox"]:hover { border-color: #4f7cff; box-shadow: 0 0 0 3px var(--glow); }
input[type="checkbox"]:checked { background: #4f7cff; border-color: #4f7cff; }
input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 6px; top: 2px;
    width: 6px; height: 10px; border: solid white; border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg); animation: checkPop 0.2s ease-out;
}
input[type="checkbox"]:disabled { opacity: 0.35; cursor: not-allowed; }
input[type="checkbox"].check-purple:checked { background: #9b59b6; border-color: #9b59b6; }
input[type="checkbox"].check-yellow:checked { background: #f1c40f; border-color: #f1c40f; }
input[type="checkbox"].check-green:checked  { background: #27ae60; border-color: #27ae60; }
input[type="checkbox"].check-orange:checked { background: #e67e22; border-color: #e67e22; }
input[type="checkbox"].check-red:checked    { background: #ff4d4d; border-color: #ff4d4d; }

/* ── Topbar ── */
.topbar {
    padding: 14px 24px;
    padding-top: calc(14px + var(--safe-top));
    background: var(--card);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 1px 0 var(--border), 0 4px 24px var(--shadow);
    gap: 10px;
    flex-wrap: wrap;
}
.topbar-left {
    display: flex; gap: 12px; align-items: center;
    min-width: 0; flex-shrink: 1;
}
.topbar-right {
    display: flex; gap: 8px; align-items: center;
    flex-wrap: wrap;
}
.date-toggle {
    cursor: pointer; font-weight: 700; padding: 8px 14px;
    background: var(--input); border-radius: 10px; transition: all 0.2s;
    color: var(--text); border: 1px solid var(--border);
    font-size: 13px; letter-spacing: 0.2px; user-select: none;
    white-space: nowrap;
}
.date-toggle:hover { border-color: #4f7cff; box-shadow: 0 0 0 3px var(--glow); transform: translateY(-1px); }
.user-profile-trigger {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; padding: 6px 10px; border-radius: 12px;
    transition: all 0.2s; user-select: none; min-width: 0;
}
.user-profile-trigger:hover { background: var(--glow); }
.nav-pfp {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    border: 2px solid #4f7cff; box-shadow: 0 0 0 3px var(--glow);
    transition: box-shadow 0.2s; flex-shrink: 0;
}
.topNavName {
    font-size: 13px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 120px;
}
.daily-total {
    font-size: 13px; font-weight: 800; color: #27ae60;
    padding: 6px 14px; background: var(--input); border-radius: 10px;
    border: 1px solid var(--border); white-space: nowrap;
}

/* ── Calendar ── */
.calendar {
    display: none; position: absolute; top: 68px; left: 16px;
    background: var(--card); padding: 14px; border-radius: 16px;
    max-height: 70vh; max-width: 300px; width: calc(100vw - 32px);
    overflow: auto; z-index: 20;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.14), 0 4px 16px var(--shadow);
    animation: popIn 0.22s cubic-bezier(0.34,1.4,0.64,1);
    /* position context for close button */
    padding-top: 14px;
    padding-right: 14px;
}
.month { margin-bottom: 10px; }
.month h4 {
    text-align: center; margin: 0 0 8px 0; color: #4f7cff;
    text-transform: uppercase; font-size: 9px; letter-spacing: 2px; font-weight: 800;
}
.days { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; text-align: center; }
.day {
    width: 28px; height: 28px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; background: var(--input); color: var(--text);
    font-size: 11px; transition: all 0.15s; border: 1px solid transparent; font-weight: 500;
}
.day:hover {
    background: #4f7cff; color: #fff; transform: scale(1.12);
    box-shadow: 0 4px 14px rgba(79,124,255,0.4); border-color: transparent;
}
.day.today {
    background: #4f7cff; box-shadow: 0 0 0 3px rgba(79,124,255,0.22), 0 4px 14px rgba(79,124,255,0.35);
    color: white; font-weight: 800;
}

/* ── Main table ── */
.container { padding: 20px; padding-bottom: calc(20px + var(--safe-bottom)); }
.table-wrapper {
    border-radius: 16px; border: 1px solid var(--border);
    overflow-x: auto; overflow-y: visible;
    box-shadow: 0 4px 32px var(--shadow);
    -webkit-overflow-scrolling: touch;
}
.schedule { width: 100%; border-collapse: collapse; background: var(--card); }
.schedule th, .schedule td {
    border: 1px solid var(--border); padding: 9px;
    text-align: center; vertical-align: top;
}
.schedule th {
    background: var(--input); font-size: 10px; text-transform: uppercase;
    letter-spacing: 1.5px; color: #888; font-weight: 800; padding: 13px 9px;
    position: sticky; top: 0; z-index: 2;
}
.time-col {
    width: 70px; min-width: 70px; background: var(--input);
    font-size: 11px; font-weight: 800; color: #4f7cff; letter-spacing: 0.3px;
    position: sticky; left: 0; z-index: 1;
}
thead .time-col { z-index: 3; }
.staff-header {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 8px 4px; min-width: 120px;
}
.staff-header img {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
    border: 2px solid #4f7cff; box-shadow: 0 0 0 3px var(--glow);
}
.staff-header span {
    font-size: 10px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1px; color: #888;
}
.cell {
    cursor: pointer; height: 38px; min-height: 38px; min-width: 140px;
    white-space: pre-line; font-size: 11px; line-height: 1.5;
    transition: background 0.18s, box-shadow 0.18s; color: var(--text);
    touch-action: manipulation;
}
.cell:hover:not(.locked) { background: rgba(79,124,255,0.055); box-shadow: inset 0 0 0 1px rgba(79,124,255,0.18); }
.cell:active:not(.locked) { background: rgba(79,124,255,0.1); }
.cell.taken {
    background: var(--taken); border-left: 3px solid #4f7cff !important;
    text-align: left; padding-left: 13px; animation: slideUp 0.2s ease-out;
}
.cell.cancelled {
    background: var(--cancelled); border-left: 3px solid #ff4d4d !important;
    text-align: left; padding-left: 13px; opacity: 0.8; animation: slideUp 0.2s ease-out;
}
.cell.locked { background: var(--input); cursor: not-allowed; opacity: 0.28; }
.cell.appt-half { border-bottom: 2px dashed rgba(79,124,255,0.35); }
.cell.appt-continue { background: var(--taken); border-left: 4px solid #4f7cff !important; padding: 0; vertical-align: top; }
.cell.appt-continue .appt-continue-bar { height: 6px; background: linear-gradient(180deg,rgba(79,124,255,0.22) 0%,transparent 100%); border-radius: 0 0 4px 4px; }
.cell.cancelled.appt-continue { border-left-color: #ff4d4d !important; }
.cell.cancelled.appt-continue .appt-continue-bar { background: linear-gradient(180deg,rgba(255,77,77,0.18) 0%,transparent 100%); }

/* Status colors */
.cell.status-modis { background: linear-gradient(90deg,#e1bee7 0%,#f5f5f5 100%) !important; border-left: 4px solid #8e24aa !important; }
.cell.status-dasazustebelia { background: linear-gradient(90deg,#fff9c4 0%,#ffffff 100%) !important; border-left: 4px solid #f1c40f !important; }
.cell.status-dasrulebuli { background: linear-gradient(90deg,#c8e6c9 0%,#f5f5f5 100%) !important; border-left: 4px solid #2e7d32 !important; }
body.dark-mode .cell.status-modis { background: linear-gradient(90deg,#4a148c 0%,#1c1c28 100%) !important; }
body.dark-mode .cell.status-dasazustebelia { background: linear-gradient(90deg,#3d3518 0%,#1c1c28 100%) !important; }
body.dark-mode .cell.status-dasrulebuli { background: linear-gradient(90deg,#1b5e20 0%,#1c1c28 100%) !important; }

/* ── Popup overlay ── */
.popup {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    display: none; align-items: center; justify-content: center;
    z-index: 100; animation: fadeIn 0.2s ease-out;
    padding: 16px; box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.popup-box {
    background: var(--card); padding: 24px; border-radius: 24px;
    width: 95%; max-width: 400px; max-height: 85vh;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column; gap: 12px;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 32px 80px rgba(0,0,0,0.18), 0 4px 16px var(--shadow);
    animation: popIn 0.3s cubic-bezier(0.34,1.5,0.64,1);
    color: var(--text);
}
.sub-window {
    display: none;
    position: absolute;
    z-index: 110;
    box-shadow: 0 24px 60px rgba(0,0,0,0.16);
    animation: slideUp 0.22s cubic-bezier(0.34,1.4,0.64,1);
}

/* ── Popup internals ── */
.menu-label {
    font-size: 10px; color: #888; margin-bottom: -8px;
    text-transform: uppercase; letter-spacing: 1.8px; font-weight: 800;
}
.menu-item {
    background: var(--input); padding: 15px 16px; border-radius: 12px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; border: 1.5px solid var(--border); transition: all 0.2s;
    color: var(--text); font-size: 14px; touch-action: manipulation;
    min-height: 48px;
}
.menu-item:hover { border-color: #4f7cff; box-shadow: 0 0 0 3px var(--glow); background: var(--card); }
.input-row { display: flex; gap: 10px; width: 100%; }
.input-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.input-group label {
    font-size: 10px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1px; color: #888;
}
textarea {
    background: var(--input); border: 1.5px solid var(--border); border-radius: 12px;
    padding: 12px; color: var(--text); resize: none; height: 80px;
    font-family: inherit; font-size: 16px; transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%; box-sizing: border-box;
}
textarea:focus { outline: none; border-color: #4f7cff; box-shadow: 0 0 0 4px var(--glow); }

/* Inputs — font-size 16px prevents iOS zoom */
input[type="text"], input[type="number"], input[type="email"],
input[type="password"], input[type="tel"] {
    padding: 14px; border-radius: 12px; border: 1.5px solid var(--border);
    background: var(--input); color: var(--text); font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%; box-sizing: border-box;
    min-height: 48px;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="tel"]:focus {
    outline: none; border-color: #4f7cff; box-shadow: 0 0 0 4px var(--glow);
}
select {
    padding: 14px; border-radius: 12px; border: 1.5px solid var(--border);
    background: var(--input); color: var(--text); font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%; box-sizing: border-box; cursor: pointer;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    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='%23888' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    min-height: 48px;
}
select:focus { outline: none; border-color: #4f7cff; box-shadow: 0 0 0 4px var(--glow); }

.sub-header { display: flex; gap: 12px; align-items: center; }
.sub-header input[type="text"] { flex: 1; }
.back-btn {
    background: none; border: none; color: #4f7cff; font-size: 22px;
    cursor: pointer; padding: 4px 8px; line-height: 1; transition: transform 0.2s;
    min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center;
}
.back-btn:hover { transform: translateX(-3px); }
.add-circle-btn {
    background: #4f7cff; border: none; color: #fff; width: 38px; height: 38px;
    border-radius: 50%; cursor: pointer; font-size: 22px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(79,124,255,0.4); transition: all 0.2s; flex-shrink: 0;
    padding: 0;
}
.add-circle-btn:hover { transform: scale(1.12); box-shadow: 0 6px 22px rgba(79,124,255,0.52); }
.list-container { max-height: 300px; overflow-y: auto; margin-top: 10px; padding-right: 4px; -webkit-overflow-scrolling: touch; }
.client-item {
    padding: 14px 16px; border-radius: 10px; margin-bottom: 5px;
    cursor: pointer; font-size: 14px; transition: all 0.18s;
    background: var(--input); color: var(--text); border: 1px solid transparent;
    animation: slideInLeft 0.18s ease-out; touch-action: manipulation;
    min-height: 48px; display: flex; align-items: center;
}
.client-item:hover { background: #4f7cff; color: #fff; transform: translateX(4px); box-shadow: 0 4px 16px rgba(79,124,255,0.3); }
.client-item:hover button { background: #fff !important; color: #9b59b6 !important; }

/* Zone picker */
.zone-scroll {
    display: flex; flex-direction: column; gap: 20px;
    max-height: 55vh; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}
.zone-column { width: 100%; }
.zone-title {
    font-weight: 800; margin-bottom: 12px; color: #4f7cff;
    font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
    border-bottom: 2px solid #4f7cff; padding-bottom: 6px;
}
.parts { display: flex; flex-direction: column; gap: 6px; }
.parts label {
    font-size: 13px; cursor: pointer; display: flex; align-items: center;
    gap: 10px; padding: 8px 8px; border-radius: 8px; transition: background 0.15s;
    min-height: 40px; touch-action: manipulation;
}
.parts label:hover { background: var(--glow); }

/* ── Checkbox row styling ── */
.check-row {
    display: flex; align-items: center; gap: 10px;
    background: var(--input); padding: 12px 14px;
    border-radius: 12px; border: 1px solid var(--border); transition: border-color 0.2s;
}
.check-row:hover { border-color: rgba(79,124,255,0.3); }
.check-row label { font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; }

/* ── Buttons ── */
button {
    padding: 14px; border: none; border-radius: 12px; color: #fff;
    font-weight: 700; cursor: pointer; font-size: 14px;
    transition: all 0.2s; letter-spacing: 0.2px;
    touch-action: manipulation; min-height: 48px;
}
button:active { transform: scale(0.97) !important; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
#saveBtn {
    background: linear-gradient(135deg,#4f7cff,#3a66e6);
    box-shadow: 0 4px 20px rgba(79,124,255,0.35);
}
#saveBtn:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(79,124,255,0.45); }
#deleteBtn { background: transparent; color: #ff4d4d; border: 1.5px solid rgba(255,77,77,0.28); margin-top: 2px; }
#deleteBtn:hover { background: rgba(255,77,77,0.08); border-color: #ff4d4d; }
.cancel-btn { background: #3a3a48; }
.cancel-btn:hover { background: #484858; }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.btn-row button { flex: 1; }
.btn-primary {
    background: linear-gradient(135deg,#4f7cff,#3a66e6);
    box-shadow: 0 4px 16px rgba(79,124,255,0.3);
}
.btn-success {
    background: linear-gradient(135deg,#27ae60,#1e8e4e);
    box-shadow: 0 4px 16px rgba(39,174,96,0.3);
}
.popup-close {
    position: absolute; top: 18px; right: 18px; cursor: pointer; color: #888;
    font-size: 17px; transition: all 0.22s; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; background: transparent; border: none;
    touch-action: manipulation;
}
.popup-close:hover { color: var(--text); background: var(--input); transform: rotate(90deg); }

/* ── Avatar upload ── */
.avatar-upload { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0; }
.avatar-preview {
    width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--border); background: var(--input); transition: border-color 0.2s;
}
.avatar-upload-btn {
    background: var(--input); border: 1.5px dashed var(--border); border-radius: 10px;
    padding: 8px 18px; color: #4f7cff; font-size: 12px; font-weight: 700;
    cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.avatar-upload-btn:hover { border-color: #4f7cff; background: var(--glow); }

/* ── Create user form ── */
.create-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.create-form .form-group { display: flex; flex-direction: column; gap: 4px; }
.create-form .form-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #888; }

/* ── Settings table ── */
.settings-table-wrap { overflow-x: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 12px; color: var(--text); min-width: 500px; }
.settings-section { border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.settings-accordion { width: 100%; display: flex; justify-content: space-between; align-items: center; background: var(--card); border: none; padding: 14px 16px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text); transition: background 0.15s; }
.settings-accordion:hover { background: var(--input); }
.accordion-arrow { font-size: 11px; color: #4f7cff; transition: transform 0.2s; }
.accordion-arrow.open { transform: rotate(180deg); }
.settings-section-body { padding: 10px 14px 14px; background: var(--bg); }
.client-mgmt-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.client-mgmt-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-mgmt-del { background: #ff4d4d; color: white; border: none; border-radius: 7px; padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer; flex-shrink: 0; min-height: 32px; }

/* ── Schedule config ── */
.schedule-config-body {
    display: flex; flex-direction: column; gap: 12px;
    margin-top: 15px; max-height: 60vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Nav buttons ── */
.nav-btn {
    height: 36px; padding: 0 14px; font-size: 12px; border-radius: 10px;
    color: white; cursor: pointer; border: none; display: flex;
    align-items: center; justify-content: center; font-weight: 700;
    transition: all 0.2s; box-sizing: border-box; letter-spacing: 0.2px;
    touch-action: manipulation; white-space: nowrap; min-height: 36px;
}
.nav-btn:active { transform: scale(0.94); }
.theme-toggle { background: #4f7cff; width: 36px; padding: 0; font-size: 16px; }
.theme-toggle:hover { box-shadow: 0 4px 18px rgba(79,124,255,0.45); transform: translateY(-1px); }
.admin-btn { background: #4f7cff; }
.admin-btn:hover { box-shadow: 0 4px 18px rgba(79,124,255,0.45); transform: translateY(-1px); }
.logout-btn { background: #3a3a48; }
.logout-btn:hover { background: #484858; transform: translateY(-1px); }

/* ── Login ── */
.login-screen {
    height: 100vh; height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); padding: 20px;
}
.login-card {
    background: var(--login-card); padding: 40px; border-radius: 28px;
    border: 1px solid var(--border); width: 100%; max-width: 360px;
    box-shadow: 0 24px 60px var(--shadow);
    animation: popIn 0.35s cubic-bezier(0.34,1.4,0.64,1);
}
#errMsg { color: #ff4d4d; text-align: center; margin-bottom: 15px; display: none; font-size: 14px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #4f7cff; }

/* ── Connection status indicator ── */
.ws-status {
    position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    padding: 8px 18px; border-radius: 20px; font-size: 12px; font-weight: 700;
    z-index: 200; transition: all 0.3s; pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.ws-status.disconnected {
    background: #ff4d4d; color: white; opacity: 1;
}
.ws-status.connected {
    background: #27ae60; color: white; opacity: 0;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .cell { height: 60px; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE LANDSCAPE / SMALL TABLET
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .topbar {
        padding: 10px 12px;
        padding-top: calc(10px + var(--safe-top));
    }
    .container { padding: 10px; }
    .time-col { width: 60px; min-width: 60px; font-size: 10px; }
    .cell { height: 55px; min-width: 130px; }
    .calendar { left: 10px; right: 10px; max-width: none; width: auto; }
    .staff-header { min-width: 110px; }
    .staff-header span { font-size: 9px; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE PORTRAIT
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px;
        padding-top: calc(8px + var(--safe-top));
        gap: 8px;
    }
    .topbar-left {
        justify-content: space-between;
        width: 100%;
    }
    .topbar-right {
        justify-content: flex-end;
        width: 100%;
        gap: 6px;
    }
    .topNavName { max-width: 80px; font-size: 11px; }
    .date-toggle { font-size: 12px; padding: 7px 12px; }
    .nav-btn { height: 34px; font-size: 11px; padding: 0 10px; }
    .theme-toggle { width: 34px; }
    .daily-total { font-size: 11px; padding: 5px 10px; }

    .container { padding: 6px; }
    .table-wrapper { border-radius: 12px; }
    .time-col { width: 55px; min-width: 55px; font-size: 10px; padding: 6px 4px; }
    .cell {
        height: 50px; min-width: 120px; font-size: 10px;
        padding: 6px 8px; line-height: 1.3;
    }
    .cell.taken, .cell.cancelled { padding-left: 10px; }
    .staff-header { min-width: 100px; padding: 6px 2px; }
    .staff-header img { width: 30px; height: 30px; }
    .staff-header span { font-size: 8px; letter-spacing: 0.5px; }

    /* Popup: full-screen on mobile */
    .popup { padding: 0; align-items: flex-end; }
    .popup-box {
        max-width: 100%; width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 92vh; max-height: 92dvh;
        padding: 20px 16px;
        padding-bottom: calc(20px + var(--safe-bottom));
        animation: slideUp 0.25s cubic-bezier(0.34,1.4,0.64,1);
    }
    .sub-window {
        border-radius: 24px 24px 0 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 92vh !important;
        max-height: 92dvh !important;
    }
    .popup-box h3 { font-size: 16px; }
    .menu-item { padding: 14px; font-size: 14px; }

    .zone-scroll {
        max-height: 55vh;
    }
    .zone-column { min-width: unset; }

    .calendar {
        top: auto; bottom: auto; left: 8px; right: 8px;
        max-width: none; width: auto;
        max-height: 60vh;
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — VERY SMALL PHONES
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    .topbar { padding: 6px 8px; gap: 6px; }
    .date-toggle { font-size: 11px; padding: 6px 10px; }
    .topNavName { display: none; }
    .nav-btn { height: 32px; font-size: 10px; padding: 0 8px; }
    .theme-toggle { width: 32px; }
    .cell { font-size: 9px; min-width: 100px; height: 45px; }
    .time-col { width: 48px; min-width: 48px; font-size: 9px; }
    .popup-box { padding: 16px 12px; gap: 10px; }
    .popup-box h3 { font-size: 15px; }
    .login-card { padding: 24px; }
}
/* ── Drag & Drop ── */
.drag-ghost {
    position: fixed;
    z-index: 99999;
    background: #4f7cff;
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(79,124,255,0.4);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.92;
    transform: scale(1.05);
    transition: opacity 0.15s;
}

.drag-over {
    background: rgba(79, 124, 255, 0.15) !important;
    outline: 2px dashed #4f7cff !important;
    outline-offset: -2px;
}

body.is-dragging .cell.taken {
    opacity: 0.6;
}

body.is-dragging .cell:not(.taken):not(.locked) {
    cursor: crosshair;
}

body.is-dragging {
    user-select: none;
    -webkit-user-select: none;
}

/* ── Client search at bottom (above keyboard) ── */
#clientListWindow {
    flex-direction: column;
}

#clientListWindow .sub-header {
    flex-shrink: 0;
}

#clientListWindow .add-circle-btn {
    width: 38px;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    align-self: center;
}

#clientListWindow .list-container {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.client-search-bottom {
    flex-shrink: 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.client-search-bottom input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--input);
    color: var(--text);
    font-size: 15px;
    outline: none;
    -webkit-appearance: none;
}

.client-search-bottom input:focus {
    border-color: #4f7cff;
    box-shadow: 0 0 0 3px rgba(79,124,255,0.15);
}