@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --navy: #16324A;
    --navy-light: #1F4A6B;
    --teal: #0E7C7B;
    --teal-light: #E4F5F4;
    --bg: #F5F7F8;
    --card: #FFFFFF;
    --border: #E1E7EA;
    --text: #1C2B33;
    --text-dim: #64778A;
    --success: #16794F;
    --success-bg: #E5F6ED;
    --warn: #A15C00;
    --warn-bg: #FFF3DF;
    --danger: #B3261E;
    --radius: 10px;
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    /* Column layout so the footer can be pushed to the bottom of a short page
       — the login screen otherwise leaves it stranded in the middle. */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* The bars keep their own height instead of being squeezed by the column. */
.topbar, .viewing-bar { flex-shrink: 0; }

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.topbar {
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
}

.topbar .brand {
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar .brand .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4FD1B5;
    box-shadow: 0 0 0 3px rgba(79,209,181,0.25);
}

.topbar nav { display: flex; gap: 4px; align-items: center; }

.topbar nav a {
    color: rgba(255,255,255,0.78);
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
}

.topbar nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.08); }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,0.14); }

.topbar .user-chip {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    margin-left: 8px;
    padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.wrap {
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    width: 100%;
}

/* Credit line, in the shape of lead-tracker's .login-credit: small, quiet and
   centred, with no background of its own.
   It carries the same max-width as .wrap and centres with auto margins, so it
   lines up with the page content instead of with the window — that is what
   makes it sit identically on every page, whatever the content width. */
.app-footer {
    flex-shrink: 0;
    margin: auto auto 0;           /* top auto holds the bottom of a short page */
    width: 100%;
    max-width: 1140px;
    padding: 16px 24px 26px;
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.7;
    letter-spacing: 0.3px;
}
.app-footer p { margin: 0; }
.app-footer b { color: var(--navy); font-weight: 600; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-head h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.2px;
}

.page-head p { margin: 0; color: var(--text-dim); font-size: 14px; }

/* ---------- Cards ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 800px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .topbar nav { display: none; }
}

.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-card .label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card .value { font-size: 26px; font-weight: 800; font-family: var(--font-mono); }
.stat-card .sub { font-size: 12.5px; color: var(--text-dim); }

/* ---------- Doctor progress card ---------- */

.doc-card {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 18px;
}

.ring {
    --pct: 0;
    --ring-color: var(--teal);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    flex-shrink: 0;
    background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), #EAEFF1 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring::after {
    content: attr(data-pct) "%";
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

.doc-card.achieved .ring { --ring-color: var(--success); }

.doc-info { flex: 1; min-width: 0; }
.doc-info .name { font-weight: 700; font-size: 15.5px; }
.doc-info .meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.doc-info .figures { font-size: 13.5px; margin-top: 6px; font-family: var(--font-mono); }
.doc-info .figures .out-of { color: var(--text-dim); font-family: var(--font-ui); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 100px;
    white-space: nowrap;
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Forms ---------- */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field { margin-bottom: 16px; }
.field small { color: var(--text-dim); display: block; margin-top: 4px; font-size: 12px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-light);
}
textarea { resize: vertical; min-height: 70px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--teal);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font-ui);
}
.btn:hover { background: #0B6564; text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #F3F5F6; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #F1C9C6; }
.btn.danger:hover { background: #FDF0EF; }
.btn.block { width: 100%; justify-content: center; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }

.form-card { max-width: 460px; margin: 40px auto; }
.form-card .logo { text-align: center; margin-bottom: 22px; font-weight: 800; color: var(--navy); font-size: 18px; }

/* ---------- Table ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 18px;
}
.flash.error { background: #FDECEA; color: var(--danger); border: 1px solid #F3C6C2; }
.flash.success { background: var(--success-bg); color: var(--success); border: 1px solid #BEE8D2; }
.flash.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #F0D9AE; }

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    margin: 30px 0 12px;
}
.section-title:first-child { margin-top: 0; }

.pill-select { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Toast popup (target achieved) ---------- */

#toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}

.toast {
    background: var(--navy);
    color: #fff;
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: toast-in 0.25s ease-out;
    border-left: 4px solid #4FD1B5;
}
.toast .emoji { font-size: 20px; }
.toast .body strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.toast .body span { font-size: 12.5px; color: rgba(255,255,255,0.75); }
.toast .close { margin-left: auto; cursor: pointer; color: rgba(255,255,255,0.5); background: none; border: none; font-size: 15px; }

@keyframes toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.helper-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---------- Review screen item tables ---------- */

.item-table th, .item-table td { padding: 6px 10px; }
.item-table td input {
    padding: 6px 8px;
    font-size: 13px;
}
.item-table td input[type=number] {
    font-family: var(--font-mono);
    text-align: right;
}
.party-block .item-rows tr:nth-child(even) { background: #FAFBFC; }
.party-block table { table-layout: fixed; }
.party-block .item-table th { padding-top: 10px; }

@media (max-width: 700px) {
    .party-block { overflow-x: auto; }
    .party-block table { min-width: 560px; }
}
