/* Clinic Management — baseline styling.
   Intentional, calm clinical palette: deep teal + slate on near-white, with a
   single coral accent. Refined per-screen later with the ui-ux-pro-max skill. */
:root {
    --teal: #0f766e;
    --teal-dark: #115e59;
    --slate: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f6f8f9;
    --card: #ffffff;
    --accent: #f97316;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color: var(--slate);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; letter-spacing: .2px; }
.brand .logo { color: var(--teal); font-weight: 700; }
.brand strong { color: var(--teal); }
.brand-lg { font-size: 1.6rem; justify-content: center; }

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0 1.25rem; height: 58px;
    background: var(--card); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a {
    color: var(--slate); text-decoration: none; font-size: .92rem;
    padding: .45rem .7rem; border-radius: 8px;
}
.mainnav a:hover { background: #f1f5f9; color: var(--teal-dark); }
.userbox { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e2e8f0; object-fit: cover; }
.uname { font-size: .9rem; }
.btn-link { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .85rem; }
.btn-link:hover { color: var(--danger); }

/* Content */
.content { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem; }
.page-title { margin: 0 0 .25rem; font-size: 1.5rem; color: var(--slate); }
.muted { color: var(--muted); margin-top: 0; }

/* Dashboard tiles */
.tiles {
    display: grid; gap: 1rem; margin-top: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .6rem; padding: 1.5rem 1rem; text-decoration: none;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--slate); box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--teal); }
.tile-icon { font-size: 1.8rem; }
.tile-label { font-size: .95rem; font-weight: 600; }

/* Login */
.login-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 50% -10%, #e6fffb 0%, var(--bg) 55%);
}
.login-card {
    width: 360px; max-width: 92vw; background: var(--card);
    border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
    padding: 2.25rem 2rem; text-align: center;
}
.login-sub { color: var(--muted); margin: .5rem 0 1.5rem; font-size: .95rem; }
.g_id_signin { display: flex; justify-content: center; }
.login-msg { min-height: 1.2em; margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.login-msg.err { color: var(--danger); }

/* ---- Shared screen chrome (Phase 2+) ---- */
.toolbar { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.input, .select {
    padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
    font-size: .92rem; color: var(--slate); background: #fff; min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.search { min-width: 240px; }

.btn {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent;
    font-size: .9rem; font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: #fff; color: var(--slate); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; font-weight: 600; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
table.grid th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #f8fafc; }
.grid-empty { text-align: center; color: var(--muted); padding: 2rem; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge.Booked { background: #e0f2fe; color: #0369a1; }
.badge.CheckedIn { background: #fef9c3; color: #854d0e; }
.badge.InConsultation { background: #ede9fe; color: #6d28d9; }
.badge.Completed { background: #dcfce7; color: #166534; }
.badge.Cancelled { background: #fee2e2; color: #991b1b; }
.badge.NoShow { background: #f1f5f9; color: #475569; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 4vh 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: 520px; max-width: 95vw; max-height: 92vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.25rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line); }
.modal .close { border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }

.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.field .input, .field .select, .field textarea { width: 100%; }
.field textarea { min-height: 70px; resize: vertical; font-family: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; }
.field-row { display: flex; gap: .75rem; }
.field-row .field { flex: 1; }

.form-msg { min-height: 1.1em; font-size: .85rem; color: var(--danger); margin-top: .25rem; }
.muted-sm { color: var(--muted); font-size: .82rem; }

/* ---- Consultation / EMR (Phase 3) ---- */
.emr-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 880px) { .emr-layout { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 1.1rem 1.25rem; }
.card + .card { margin-top: 1rem; }
.card h3 { margin: 0 0 .85rem; font-size: 1rem; color: var(--slate); }

.pt-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pt-header .pt-name { font-size: 1.2rem; font-weight: 700; }
.pt-header .chip { background: #f1f5f9; border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; color: var(--slate); }
.pt-header .chip.warn { background: #fef2f2; color: #991b1b; }

.rx-table { width: 100%; border-collapse: collapse; }
.rx-table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: .25rem .35rem; }
.rx-table td { padding: .2rem .35rem; }
.rx-table .input { width: 100%; padding: .4rem .5rem; }
.rx-row-del { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: 1.1rem; line-height: 1; }

.history-item { padding: .6rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.history-item:last-child { border-bottom: 0; }
.history-item .h-date { font-weight: 600; }
.history-empty { color: var(--muted); font-size: .85rem; }

.actions-bar { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }

/* ---- Pharmacy (Phase 4) ---- */
table.grid tr.row-low td { background: #fef2f2; }
.tag-low { display: inline-block; margin-left: .4rem; padding: .05rem .45rem; border-radius: 999px; background: #fee2e2; color: #991b1b; font-size: .7rem; font-weight: 700; }
.disp-item { display: grid; grid-template-columns: 1fr 1.4fr 90px; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.disp-item:last-child { border-bottom: 0; }
.disp-item .rx-name { font-weight: 600; }
.disp-item .muted-sm { font-weight: 400; }

/* ---- Reports (Phase 8) ---- */
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 1.25rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.stat .stat-val { font-size: 1.7rem; font-weight: 700; color: var(--teal-dark); line-height: 1.1; }
.stat .stat-label { color: var(--muted); font-size: .82rem; margin-top: .3rem; }
.stat .stat-sub { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
