/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f4f8; color: #222; min-height: 100vh; }
a { text-decoration: none; color: inherit; }

/* ===== LAYOUT ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px; background: #1a1a2e; color: #fff;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    transition: transform 0.3s;
}
.sidebar-logo {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo h1 { font-size: 18px; font-weight: 800; color: #00c9c8; letter-spacing: 0.5px; }
.sidebar-logo p  { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 20px; font-size: 14px; color: rgba(255,255,255,0.7);
    cursor: pointer; border-left: 3px solid transparent;
    transition: all 0.2s;
}
.nav-item:hover  { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(0,201,200,0.12); color: #00c9c8; border-left-color: #00c9c8; }
.nav-item .icon  { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px; color: rgba(255,255,255,0.4);
}
.sidebar-footer .logout-btn {
    display: flex; align-items: center; gap: 8px;
    color: rgba(255,255,255,0.5); cursor: pointer; font-size: 13px;
    padding: 6px 0; transition: color 0.2s;
}
.sidebar-footer .logout-btn:hover { color: #ff6b6b; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 240px; flex: 1;
    display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
    background: #fff; padding: 14px 28px;
    border-bottom: 1px solid #e5e9f0;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 90;
}
.topbar-title { font-size: 18px; font-weight: 700; color: #1a1a2e; }
.topbar-user   { font-size: 13px; color: #666; display: flex; align-items: center; gap: 8px; }
.topbar-user .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #00c9c8; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
}
.page-content { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    padding: 24px; margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; color: #1a1a2e; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px; font-size: 13px;
    font-weight: 600; cursor: pointer; border: none;
    transition: all 0.2s; white-space: nowrap;
}
.btn-primary   { background: #00c9c8; color: #fff; }
.btn-primary:hover { background: #00b0af; }
.btn-secondary { background: #f0f4f8; color: #444; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger    { background: #ff5252; color: #fff; }
.btn-danger:hover { background: #e04040; }
.btn-success   { background: #4caf50; color: #fff; }
.btn-success:hover { background: #3d9140; }
.btn-warning   { background: #ff9800; color: #fff; }
.btn-warning:hover { background: #e08800; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 6px 8px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 9px 13px; border: 1.5px solid #dde3ec;
    border-radius: 8px; font-size: 14px; color: #222;
    transition: border-color 0.2s; background: #fff;
}
.form-control:focus { outline: none; border-color: #00c9c8; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* Schedule days checkboxes */
.days-grid {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px;
}
.day-check { display: none; }
.day-label {
    padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
    border: 1.5px solid #dde3ec; color: #666; cursor: pointer;
    transition: all 0.2s;
}
.day-check:checked + .day-label {
    background: #00c9c8; color: #fff; border-color: #00c9c8;
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left; padding: 10px 14px;
    background: #f8fafc; border-bottom: 2px solid #e5e9f0;
    font-weight: 700; color: #555; white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid #f0f4f8; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcff; }

/* ===== BADGES ===== */
.badge {
    display: inline-block; padding: 3px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger  { background: #ffebee; color: #c62828; }
.badge-info    { background: #e3f2fd; color: #1565c0; }
.badge-warning { background: #fff8e1; color: #e65100; }
.badge-gray    { background: #f0f4f8; color: #555; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: 14px;
    padding: 28px; width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    position: relative;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title { font-size: 17px; font-weight: 700; color: #1a1a2e; }
.modal-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: #f0f4f8; border: none; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    color: #666; transition: background 0.2s;
}
.modal-close:hover { background: #ffebee; color: #c62828; }
.modal-footer {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid #f0f4f8;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px; border-radius: 8px;
    font-size: 13px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error   { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ===== TOAST ===== */
#toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
    color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease; max-width: 320px;
}
.toast-success { background: #4caf50; }
.toast-error   { background: #ff5252; }
.toast-info    { background: #2196f3; }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border-radius: 12px;
    padding: 20px; box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    display: flex; flex-direction: column; gap: 6px;
}
.stat-value { font-size: 28px; font-weight: 800; color: #1a1a2e; }
.stat-label { font-size: 12px; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-icon  { font-size: 24px; margin-bottom: 4px; }

/* ===== QR CARD ===== */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.qr-card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    padding: 20px; text-align: center;
}
.qr-card h3 { font-size: 14px; font-weight: 700; color: #1a1a2e; margin-bottom: 4px; }
.qr-card p  { font-size: 12px; color: #888; margin-bottom: 12px; }
.qr-card img { width: 140px; height: 140px; margin: 0 auto 12px; display: block; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ===== SOW TASKS ===== */
.task-list { list-style: none; }
.task-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid #f0f4f8;
}
.task-item:last-child { border-bottom: none; }
.task-drag  { cursor: grab; color: #bbb; font-size: 18px; padding-top: 2px; }
.task-body  { flex: 1; }
.task-desc  { font-size: 14px; color: #222; margin-bottom: 4px; }
.task-freq  { font-size: 11px; color: #888; font-weight: 600; }
.task-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-card {
    background: #fff; border-radius: 16px;
    padding: 40px; width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: #00c9c8; }
.login-logo p  { font-size: 13px; color: #888; margin-top: 4px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: #aaa; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== HAMBURGER ===== */
.hamburger {
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    gap: 5px; width: 36px; height: 36px;
    background: none; border: none; cursor: pointer; padding: 4px;
    border-radius: 8px; flex-shrink: 0;
}
.hamburger span {
    display: block; width: 22px; height: 2px;
    background: #1a1a2e; border-radius: 2px;
    transition: all 0.25s;
}
.hamburger:hover { background: #f0f4f8; }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    /* Show hamburger */
    .hamburger { display: flex; }

    /* Sidebar slides in over content */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-content { padding: 16px; }

    /* Stats grid: 2 columns on tablet */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Tables: horizontal scroll */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 540px; }

    /* Cards full width */
    .card { margin-bottom: 14px; }

    /* Modal full screen on mobile */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal, .modal-wide {
        max-width: 100% !important; width: 100% !important;
        border-radius: 18px 18px 0 0;
        max-height: 92vh; overflow-y: auto;
    }

    /* Form rows stack vertically */
    .form-row { flex-direction: column; gap: 0; }

    /* QR grid: single column */
    .qr-grid { grid-template-columns: 1fr !important; }
    .qr-card { padding: 16px; }

    /* Topbar */
    .topbar { padding: 12px 16px; }
    .topbar-title { font-size: 15px; }
}

@media (max-width: 480px) {
    /* Stats: single column on small phones */
    .stats-grid { grid-template-columns: 1fr; }

    /* Buttons: stack in action cells */
    .btn-sm { font-size: 11px; padding: 5px 8px; }

    /* Page content tighter */
    .page-content { padding: 12px; }

    /* Freq picker full width */
    .freq-picker-drop { left: 0; right: 0; }

    /* Linked sites picker */
    .linked-sites-picker { max-height: 160px; }

    /* SOW add task row */
    .add-task-row { flex-direction: column; }
    .add-task-row input[type=text] { width: 100%; }
    .add-task-row select { width: 100%; }
    .add-task-row button { width: 100%; }
}

/* ===== SEARCH & FILTERS ===== */
.search-bar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
}
.search-input {
    flex: 1; min-width: 200px; padding: 8px 13px;
    border: 1.5px solid #dde3ec; border-radius: 8px;
    font-size: 13px; transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: #00c9c8; }

/* ===== FREQUENCY BADGE COLORS ===== */
.freq-weekly      { background: #e3f2fd; color: #1565c0; }
.freq-fortnightly { background: #f3e5f5; color: #6a1b9a; }
.freq-monthly     { background: #e8f5e9; color: #2e7d32; }
.freq-quarterly   { background: #fff8e1; color: #e65100; }
.freq-halfyearly  { background: #fce4ec; color: #880e4f; }
.freq-yearly      { background: #e0f2f1; color: #004d40; }
.freq-asrequired  { background: #f5f5f5; color: #555; }
/* ===== FREQUENCY PICKER ===== */
.freq-display-btn {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 9px 13px; border: 1.5px solid #dde3ec; border-radius: 8px;
    background: #fff; font-size: 13px; color: #1a1a2e; cursor: pointer;
    text-align: left; transition: border-color 0.2s;
}
.freq-display-btn:hover { border-color: #00c9c8; }

.freq-picker-drop {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1.5px solid #dde3ec; border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 9999;
    overflow: hidden;
}
.freq-radio-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 16px; cursor: pointer; font-size: 13px; color: #1a1a2e;
    transition: background 0.15s; border-bottom: 1px solid #f0f3f8;
}
.freq-radio-item:last-child { border-bottom: none; }
.freq-radio-item:hover { background: #f4fffe; }
.freq-radio-dot {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid #c0c8d4; flex-shrink: 0; transition: all 0.15s;
    display: inline-block;
}
.freq-radio-dot.active {
    border-color: #00c9c8;
    background: #00c9c8;
    box-shadow: inset 0 0 0 3px #fff;
}

/* ===== CUSTOM FREQ MODAL ===== */
.cm-ends-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.cm-end-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    font-size: 13px; color: #1a1a2e; transition: background 0.15s;
}
.cm-end-row:hover { background: #f4fffe; }
.cm-end-label { flex: 1; }
.cm-end-input { font-size: 13px; }

/* ===== LINKED SITES PICKER ===== */
.linked-sites-picker {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 200px; overflow-y: auto;
    border: 1.5px solid #dde3ec; border-radius: 8px;
    padding: 6px 4px;
}
.linked-site-check-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 7px; cursor: pointer;
    transition: background 0.15s; font-size: 13px;
}
.linked-site-check-item:hover { background: #f4fffe; }
.linked-site-check-item input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: #00c9c8; cursor: pointer; flex-shrink: 0;
}
.linked-site-name { font-weight: 600; color: #1a1a2e; flex: 1; }
.linked-site-addr { font-size: 11px; color: #999; }

/* ===== SOW TABS & PASTE IMPORT ===== */
.sow-tab-btns { display: flex; gap: 4px; }
.sow-tab-btn {
    padding: 4px 12px; border-radius: 20px; border: 1.5px solid #dde3ec;
    background: #fff; font-size: 12px; font-weight: 600; color: #666; cursor: pointer;
    transition: all 0.15s;
}
.sow-tab-btn.active { background: #00c9c8; border-color: #00c9c8; color: #fff; }
.sow-tab-btn:hover:not(.active) { border-color: #00c9c8; color: #00c9c8; }

.sow-paste-hint {
    font-size: 12px; color: #888; margin-bottom: 8px; line-height: 1.5;
}
.sow-paste-area {
    width: 100%; min-height: 140px; padding: 10px 12px;
    border: 1.5px solid #dde3ec; border-radius: 8px;
    font-size: 13px; font-family: inherit; resize: vertical;
    box-sizing: border-box; transition: border-color 0.2s;
}
.sow-paste-area:focus { outline: none; border-color: #00c9c8; }

.sow-preview-item { background: #f0fffe; border-color: #b2eeee; }
.sow-preview-freq-sel {
    padding: 3px 8px; border: 1.5px solid #dde3ec; border-radius: 6px;
    font-size: 12px; background: #fff; cursor: pointer;
}

/* ===== QR TWO-COLUMN LAYOUT ===== */
.qr-two-col { display: flex; gap: 16px; margin-top: 12px; }
.qr-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px; border-radius: 10px; border: 1.5px solid #e5e9f0; }
.qr-col-label { font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 20px; }
.staff-label  { background: #e3f2fd; color: #1565c0; }
.client-label { background: #e8f5e9; color: #2e7d32; }
.qr-url { font-size: 10px; color: #1a73e8; word-break: break-all; text-align: center; }
.qr-empty { height: 80px; display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 12px; }