:root {
    --bg: #f1faf3;
    --sidebar: #e1f3e6;
    --sidebar-soft: #cdebd5;
    --card: #ffffff;
    --ink: #173827;
    --muted: #63796a;
    --accent: #54ad70;
    --accent-strong: #347f4d;
    --line: #d5e8d9;
    --warn: #fff5d6;
    --badge-bg: #e4f5e8;
    --danger: #ef4444;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Cairo', sans-serif;
    background-image: linear-gradient(135deg, #f4fbf5 0%, #edf8ef 48%, #e7f5ea 100%);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.weekday-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.weekday-options label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f5fbf6;
    cursor: pointer;
    font-size: 0.9rem;
}

.weekday-options input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.service-selection-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
}

.provider-service-row {
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcfd;
}

.service-row-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.35;
}

.service-row-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-row-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 5px;
}

.service-row-fields input[type="number"] {
    min-width: 0;
    padding: 5px 7px;
    border-radius: 6px;
    font-size: 11px;
}

.service-row-invalid {
    border-color: var(--danger);
    background: #fff5f5;
}

.service-row-invalid input:not([type="checkbox"]):placeholder-shown,
.service-row-invalid input:not([type="checkbox"]):invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.service-availability {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.service-availability input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
}

.provider-service-enabled {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.permission-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f2faf4;
    cursor: pointer;
}

.permission-option input[type="checkbox"],
#adminUsersTable input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: #214832;
    padding: 20px 16px;
    flex-shrink: 0;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 18px;
    border-bottom: 1px solid #c6e2cd;
}

.brand-mark {
    width: 92px;
    height: 52px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.login-logo {
    display: block;
    width: min(260px, 78vw);
    height: auto;
    margin: 0 auto 14px;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.sidebar small {
    color: #66816e;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
}

.nav-link {
    display: block;
    padding: 11px 12px;
    border-radius: 12px;
    color: #315a3d;
    background: transparent;
    transition: 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    background: linear-gradient(110deg, #d2f0d9, #e9f8ec);
    color: #286a3f;
}

.sidebar-card {
    margin-top: 24px;
    background: linear-gradient(145deg, #f5fcf6, #dff2e4);
    border: 1px solid #c8e4ce;
    border-radius: 14px;
    padding: 16px 12px;
}

.mini-label {
    font-size: 12px;
    opacity: 0.72;
    margin-bottom: 6px;
}

.auth-status {
    font-weight: 700;
    margin-bottom: 12px;
    color: #347f4d;
}

.content-area {
    flex: 1;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: rgba(255,255,255,0.85);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    z-index: 20;
}

.topbar h1 {
    margin: 0;
    font-size: 1.6rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.badge.warning {
    background: #fff5d6;
    color: #9a6a00;
}

.wrap {
    max-width: 1200px;
    padding: 24px 28px 40px;
}

section {
    margin-bottom: 28px;
    scroll-margin-top: 80px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.kpi .muted {
    color: var(--muted);
    font-size: 13px;
}

.kpi strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
}

.muted { color: var(--muted); }

h1, h2, h3 { margin: 0 0 10px; }

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    margin: 12px 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-size: 15px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(84, 173, 112, 0.16);
}

textarea { resize: vertical; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    text-align: right;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    background: #f1f8f2;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn.primary:hover {
    background: var(--accent-strong);
    color: white;
}

.fluid { width: 100%; }

.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 18px;
    flex-wrap: wrap;
}

.map-box {
    margin-top: 18px;
}

#map {
    height: 260px;
    border-radius: 12px;
    border: 1px solid var(--line);
    overflow: hidden;
    margin-top: 8px;
    background: #dfeff5;
}

.warn {
    background: var(--warn);
    border: 1px solid #f5e2a8;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 13px;
}

.providers-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.provider-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

.provider-card h4 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.provider-priority-note {
    color: #d92d20;
    font-size: 11px;
    font-weight: 700;
    margin: 0 0 10px;
    text-align: right;
}

.provider-distance {
    color: #d92d20;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 8px;
}

.provider-meta {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}

.provider-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.tag {
    display: inline-block;
    background: #e7f5e9;
    color: #347f4d;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
}

.red-tag {
    background: #fff1f0;
    color: #d92d20;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #e3f5e7 0%, #bfe8ca 48%, #78c68d 100%);
    padding: 24px;
}

.login-box {
    width: min(440px, 100%);
    background: rgba(255,255,255,0.96);
    border: 1px solid #c6e6cd;
    border-radius: 14px;
    padding: 28px 24px;
    box-shadow: 0 18px 44px rgba(34, 91, 52, 0.16);
}

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

.login-logo {
    width: min(360px, 90%);
    height: auto;
    margin: 0 auto 12px;
    border-radius: 0;
    background: transparent;
    display: block;
    object-fit: contain;
}

.hidden { display: none !important; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.48);
}

.modal-content {
    width: min(900px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 20px;
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.icon-btn {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-size: 17px;
}

.icon-btn.danger {
    border-color: #f1b8b8;
    color: #b42318;
}

.icon-btn.danger:hover {
    border-color: #b42318;
    background: #fff1f0;
}

.report-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0 20px;
}

.report-detail-grid > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f8fafb;
}

.report-detail-grid strong {
    color: var(--muted);
    font-size: 11px;
}

.report-detail-grid span,
.report-notes {
    font-size: 13px;
}

.admin-card { max-width: 520px; }
.stack-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (max-width: 960px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .row, .grid, .service-selection-grid { grid-template-columns: 1fr; }
    .wrap { padding: 16px; }
    .topbar { padding: 14px 16px; }
}

    flex-wrap: wrap;
    margin-top: 16px;
}

.footer {
    padding: 30px 0 12px;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

@media (max-width: 760px) {
    .grid { grid-template-columns: 1fr 1fr; }
    .row { grid-template-columns: 1fr; }
    .brand-wrap { flex-direction: column; align-items: flex-start; }
    .provider .top { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
    .grid { grid-template-columns: 1fr; }
    .wrap { padding: 12px; }
}

/* Modern visual layer: keeps the existing DOM and JavaScript hooks intact. */
:root {
    --bg: #f5f8f6;
    --sidebar: #103b2a;
    --sidebar-soft: #1b5940;
    --card: #ffffff;
    --ink: #18332a;
    --muted: #6c7d74;
    --accent: #2f9a67;
    --accent-strong: #20764d;
    --line: #e2ebe5;
    --shadow: 0 12px 32px rgba(25, 55, 42, 0.07);
}

body {
    background: var(--bg);
    background-image: radial-gradient(circle at top right, rgba(130, 210, 158, 0.18), transparent 34%), linear-gradient(135deg, #f8fbf9 0%, #eef5f0 100%);
}

.sidebar {
    width: 272px;
    padding: 24px 18px;
    background: linear-gradient(180deg, #103b2a 0%, #174d36 100%);
    color: #eefaf1;
}

.brand-box {
    gap: 10px;
    padding: 4px 4px 22px;
    border-bottom-color: rgba(255, 255, 255, 0.14);
}

.brand-name { color: #ffffff; font-size: 1.15rem; }
.sidebar small { color: #b7d6c0; }
.brand-mark { width: 102px; height: 56px; }

.side-nav { gap: 5px; margin-top: 28px; }

.nav-link {
    padding: 12px 14px;
    border-radius: 10px;
    color: #c4dfcc;
    font-size: 14px;
}

.nav-link:hover, .nav-link.active {
    background: #e8f6ec;
    color: #174d36;
}

.sidebar-card {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    border-radius: 12px;
}

.auth-status { color: #a8e7b9; }
.content-area { background: transparent; }

.topbar {
    padding: 20px 34px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: #dce8df;
}

.topbar h1 { font-size: 1.45rem; letter-spacing: 0; }
.wrap { max-width: 1380px; padding: 30px 34px 48px; }
section { margin-bottom: 22px; }

.card {
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

#admin-dashboard > .grid,
#call-dashboard > .grid { gap: 14px; }

.kpi {
    position: relative;
    overflow: hidden;
    min-height: 118px;
    border-top: 3px solid var(--accent);
}

.kpi strong { color: var(--ink); font-size: 1.85rem; }
.kpi .muted { font-weight: 700; }
.kpi:nth-child(2) { border-top-color: #4e83c4; }
.kpi:nth-child(3) { border-top-color: #d4a43a; }
.kpi:nth-child(4) { border-top-color: #a66ac3; }

.section-head { margin-bottom: 18px; }
.section-head h3 { font-size: 1.12rem; }

input, select, textarea {
    border-color: #d9e6dd;
    border-radius: 8px;
    background: #fcfefd;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 154, 103, 0.14);
}

.btn {
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 700;
}

.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

table { font-size: 13px; }
th, td { padding: 12px 11px; }
th { position: sticky; top: 0; z-index: 1; background: #f1f7f3; font-weight: 700; }
tbody tr:hover { background: #f7fbf8; }

.provider-card {
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(25, 55, 42, 0.05);
}

.login-screen {
    background: radial-gradient(circle at 15% 20%, rgba(255,255,255,0.72), transparent 28%), linear-gradient(135deg, #dcefe2 0%, #a6d9b5 100%);
}

.login-box {
    border-radius: 16px;
    padding: 34px 30px;
    box-shadow: 0 22px 55px rgba(23, 73, 50, 0.16);
}

.login-header h2 { font-size: 1.25rem; }

@media (max-width: 960px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; padding: 14px 16px; }
    .brand-box { padding-bottom: 12px; }
    .side-nav { flex-direction: row; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
    .nav-link { white-space: nowrap; }
    .sidebar-card { margin-top: 12px; }
    .wrap { padding: 24px; }
}

@media (max-width: 640px) {
    .topbar { padding: 14px 16px; }
    .topbar h1 { font-size: 1.2rem; }
    .wrap { padding: 16px 12px 32px; }
    .card { padding: 15px; }
    .brand-mark { width: 84px; height: 46px; }
    .topbar-actions { gap: 6px; }
    .badge { padding: 5px 8px; }
}

.call-service-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
    padding: 2px;
}

.call-service-option {
    display: grid;
    grid-template-columns: 20px 42px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.call-service-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.call-service-category {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.call-service-category input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
}

.call-service-group h4 {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.call-service-group-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.call-service-option:has(input:checked) {
    border-color: var(--accent);
    background: #eef8f1;
}

.call-service-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.call-service-code {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    direction: ltr;
}

.call-service-name { font-size: 13px; line-height: 1.4; }
.service-prompt { grid-column: 1 / -1; padding: 10px 4px; }

.order-status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 220px;
}

.status-action {
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.status-action:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.status-action.active { background: #eaf6ee; border-color: #9bcdae; color: var(--accent-strong); }
.status-action:disabled { cursor: default; opacity: 0.75; }
.status-action:last-child { border-color: #f1c4c0; color: #b42318; }
.new-order-highlight { animation: order-highlight 2s ease-out; }

.area-picker { position: relative; }

.area-suggestions {
    position: absolute;
    inset: calc(100% + 4px) 0 auto;
    z-index: 35;
    display: flex;
    max-height: 250px;
    flex-direction: column;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(20, 50, 35, 0.16);
}

.area-suggestion {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    text-align: right;
}

.area-suggestion:hover, .area-suggestion:focus-visible {
    outline: none;
    background: #edf7f0;
    color: var(--accent-strong);
}

.area-suggestion-empty { padding: 10px; color: var(--muted); font-size: 13px; }

@keyframes order-highlight {
    0%, 35% { background: #e3f6e9; }
    100% { background: transparent; }
}

@media (max-width: 640px) {
    .call-service-options { max-height: 320px; }
    .call-service-group-items { grid-template-columns: 1fr; }
    .order-status-actions { min-width: 190px; }
}
