/* ============================================================
   Priatech — interface autenticada
   Tokens e componentes seguindo o desenho de referencia:
   menu lateral fixo, barra de topo, cartoes de metrica e
   grade de dois paineis.
   ============================================================ */

:root {
    /* Marca */
    --primary:      #419989;
    --primary-dark: #2F7D71;
    --primary-light:#6BB5A8;
    --primary-soft: #E9F5F3;
    --secondary:    #1F2A37;

    /* Superficies */
    --bg:          #F5F7F6;
    --surface:     #ffffff;
    --surface-alt: #F7F9F8;
    --border:      #EDF0EF;
    --border-strong: #E3E8E6;

    /* Texto */
    --text:       #1F2A37;
    --text-muted: #758086;
    --text-faint: #A8ACAB;

    /* Familias de destaque */
    --blue-soft:   #EFF6FF;
    --blue-ink:    #2A6AA8;
    --yellow-soft: #FEF3C6;
    --yellow-ink:  #8B6B3C;
    --purple-soft: #EDEAFF;
    --purple-ink:  #5B4FB8;
    --red-soft:    #FFF5F6;

    --danger:  #C0392B;
    --success: #2F7D71;

    --radius-card:    12px;
    --radius-control: 8px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-pop:  0 8px 24px rgba(16, 24, 40, 0.1);
    --transition: 0.18s ease-in-out;

    --sidebar-w: 248px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { line-height: 1.3; font-weight: 600; }

/* ============================================================
   Shell: lateral + conteudo
   ============================================================ */

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

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 60;
    transition: width var(--transition), transform var(--transition);
}

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* Marca */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    height: var(--topbar-h);
    padding: 0 0.9rem 0 1rem;
    flex-shrink: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    min-width: 0;
}

.app-brand:hover { text-decoration: none; }

.app-logo {
    height: 30px;
    max-height: 30px;
    width: auto;
    max-width: 130px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.sidebar-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

.sidebar-collapse:hover { background: var(--surface-alt); color: var(--text-muted); }

/* Cartao do usuario */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0.75rem 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-alt);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition);
}

.sidebar-user:hover { border-color: var(--primary-light); text-decoration: none; }

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.6875rem;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.625rem; }

/* Seletor de clinica */
.sidebar-clinic { margin: 0 0.75rem 0.5rem; position: relative; }

.sidebar-clinic > summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
}

.sidebar-clinic > summary::-webkit-details-marker { display: none; }
.sidebar-clinic > summary:hover { border-color: var(--primary-light); color: var(--text); }
.sidebar-clinic-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-clinic-caret { margin-left: auto; flex-shrink: 0; }

.sidebar-clinic-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    padding: 0.3rem;
    z-index: 20;
}

.sidebar-clinic-list a {
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-clinic-list a:hover { background: var(--primary-soft); text-decoration: none; }

/* Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0.75rem 1rem;
}

.nav-section-label {
    padding: 1rem 0.6rem 0.35rem;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.nav-item:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav-item svg { flex-shrink: 0; }
.nav-item-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.nav-item--soon { color: var(--text-faint); cursor: default; }
.nav-item--soon:hover { background: none; color: var(--text-faint); }

.soon-chip {
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.1rem 0.35rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.6rem 0.75rem 0.9rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-item--danger { color: var(--danger); }
.nav-item--danger:hover { background: var(--red-soft); color: var(--danger); }

/* Lateral recolhida (so icones) */
.app-shell--collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
.app-shell--collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
.app-shell--collapsed .app-logo { max-width: 32px; }
.app-shell--collapsed .sidebar-brand { padding: 0 0.7rem; justify-content: center; }
.app-shell--collapsed .sidebar-collapse { display: none; }
.app-shell--collapsed .sidebar-user { justify-content: center; padding: 0.5rem; }
.app-shell--collapsed .sidebar-user-info,
.app-shell--collapsed .sidebar-clinic,
.app-shell--collapsed .nav-item-label,
.app-shell--collapsed .nav-dot,
.app-shell--collapsed .soon-chip,
.app-shell--collapsed .nav-section-label { display: none; }
.app-shell--collapsed .nav-item { justify-content: center; padding: 0.55rem; }

.sidebar-backdrop { display: none; }

/* ============================================================
   Barra de topo
   ============================================================ */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--topbar-h);
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 420px;
}

.topbar-search svg {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
}

.topbar-search input {
    width: 100%;
    height: 36px;
    padding: 0 0.75rem 0 2.1rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    font-family: inherit;
    font-size: 0.8125rem;
    color: var(--text);
}

.topbar-search input::placeholder { color: var(--text-faint); }
.topbar-search input:disabled { background: var(--surface-alt); cursor: not-allowed; }
.topbar-search input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(65, 153, 137, 0.12);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
    flex-shrink: 0;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.icon-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.icon-btn:disabled { color: var(--text-faint); cursor: not-allowed; background: var(--surface-alt); }
.icon-btn:disabled:hover { border-color: var(--border-strong); color: var(--text-faint); }

.app-content {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Compatibilidade com o container antigo */
.app-container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Cabecalho de pagina */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-title { font-size: 1.375rem; font-weight: 600; }
.page-subtitle { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.15rem; }

.home-greeting { margin-bottom: 1.35rem; }
.home-greeting h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.home-greeting p { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.2rem; }

.pending-list { list-style: none; }
.pending-item {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}
.pending-item:last-child { border-bottom: none; padding-bottom: 0; }
.pending-item:first-child { padding-top: 0; }
.pending-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 0.4rem;
    flex-shrink: 0;
}
.pending-dot--yellow { background: #E3B341; }
.pending-dot--blue   { background: #3B82F6; }
.pending-dot--red    { background: #E25C5C; }
.pending-dot--green  { background: var(--primary); }
.pending-body { min-width: 0; flex: 1; }
.pending-title { font-size: 0.8125rem; font-weight: 500; color: var(--text); }
.pending-link { display: inline-block; margin-top: 0.2rem; font-size: 0.75rem; font-weight: 500; }

.appt-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.appt-row:last-child { border-bottom: none; }
.appt-time { width: 54px; font-size: 0.8125rem; color: var(--text-muted); flex-shrink: 0; }
.appt-person { min-width: 0; flex: 1; }

/* ============================================================
   Primitivas
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.card h2 { font-size: 1.125rem; }
.card h3 { font-size: 1rem; }
.card h2, .card h3 { margin-bottom: 0.9rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 36px;
    padding: 0 0.95rem;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.btn-ghost { background: none; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }
.btn-warning { background: #e67e22; color: #fff; }
.btn-warning:hover { background: #ca6f1e; color: #fff; }
.btn-sm { height: 30px; padding: 0 0.7rem; font-size: 0.75rem; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Formularios */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text);
}

.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 38px;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(65, 153, 137, 0.12);
}

.form-group textarea { min-height: 100px; resize: vertical; }

.form-group input[type="radio"],
.form-group input[type="checkbox"] {
    width: auto;
    min-height: 0;
    padding: 0;
    border: none;
    accent-color: var(--primary);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.checkbox-group label,
.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    margin-bottom: 0.35rem;
}

/* Avisos */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-control);
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    border: 1px solid transparent;
}

.alert-error { background: #FDF1F0; color: #96281B; border-color: #F5D3CF; }
.alert-success { background: var(--primary-soft); color: var(--primary-dark); border-color: #C8E4DE; }

/* Tabelas: cabecalho leve e linhas separadas, sem moldura */
table { width: 100%; border-collapse: collapse; }

th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: none;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.75rem;
    text-align: left;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-alt); }

/* Selos */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active    { background: var(--primary-soft); color: var(--primary-dark); }
.badge-inactive  { background: #FDF1F0; color: #96281B; }
.badge-draft     { background: var(--yellow-soft); color: var(--yellow-ink); }
.badge-attention { background: var(--yellow-soft); color: var(--yellow-ink); }
.badge-info      { background: var(--blue-soft); color: var(--blue-ink); }
.badge-purple    { background: var(--purple-soft); color: var(--purple-ink); }
.badge-neutral   { background: var(--bg); color: var(--text-muted); }

/* ============================================================
   Cartoes de metrica
   ============================================================ */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    position: relative;
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1.1rem;
    color: inherit;
    text-decoration: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

a.metric-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 12px rgba(65, 153, 137, 0.1);
    text-decoration: none;
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    margin-bottom: 0.85rem;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.metric-icon--blue   { background: var(--blue-soft); color: var(--blue-ink); }
.metric-icon--yellow { background: var(--yellow-soft); color: var(--yellow-ink); }
.metric-icon--purple { background: var(--purple-soft); color: var(--purple-ink); }

.metric-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.metric-label { font-size: 0.8125rem; color: var(--text); margin-top: 0.2rem; }
.metric-note { font-size: 0.6875rem; color: var(--text-faint); margin-top: 0.1rem; }

.metric-corner {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    color: var(--text-faint);
    opacity: 0.55;
    transition: opacity var(--transition);
}

a.metric-card:hover .metric-corner { opacity: 1; color: var(--primary); }

.metric-card--soon { background: var(--surface-alt); }
.metric-card--soon .metric-value { color: var(--text-faint); }

/* ============================================================
   Grade de paineis e atalhos
   ============================================================ */

.panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.panel-main > .card:last-child,
.panel-aside > .card:last-child { margin-bottom: 0; }

.shortcut-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.shortcut {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    font-size: 0.78125rem;
    font-weight: 600;
    text-align: center;
    background: var(--primary-soft);
    color: var(--primary-dark);
    text-decoration: none;
    transition: filter var(--transition);
}

.shortcut:hover { filter: brightness(0.96); text-decoration: none; }
.shortcut--blue   { background: var(--blue-soft); color: var(--blue-ink); }
.shortcut--yellow { background: var(--yellow-soft); color: var(--yellow-ink); }
.shortcut--purple { background: var(--purple-soft); color: var(--purple-ink); }

/* ============================================================
   Blocos de conteudo das telas iniciais
   ============================================================ */

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.section-head h2, .section-head h3 { margin-bottom: 0; }
.section-hint { font-size: 0.78125rem; color: var(--text-muted); margin-top: 0.2rem; }

.card-attention { border-color: #F2E2BE; background: #FFFDF7; }
.card-attention > .section-head h3 { color: var(--yellow-ink); }

.attention-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.attention-item:last-child { border-bottom: none; padding-bottom: 0; }
.attention-item-info { flex: 1; min-width: 180px; }
.attention-item-title { font-weight: 600; font-size: 0.84375rem; }
.attention-item-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.attention-item-meta .sep { color: var(--border-strong); }
.attention-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.attention-actions form { display: inline; }

/* Atalhos em formato de cartao (telas internas) */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.75rem; }

.tile {
    display: block;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.tile:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 12px rgba(65, 153, 137, 0.1);
    text-decoration: none;
}

.tile-title { font-weight: 600; font-size: 0.84375rem; color: var(--primary-dark); }
.tile-desc { font-size: 0.71875rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Estado vazio: sempre com o proximo passo */
.empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    background: var(--surface-alt);
}

.empty-state p { color: var(--text-muted); font-size: 0.8125rem; margin-bottom: 0.75rem; }
.empty-state p:last-child { margin-bottom: 0; }

/* Agrupamento por clinica */
.clinic-group {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.clinic-group:last-child { margin-bottom: 0; }

.clinic-group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.clinic-group-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-weight: 600;
    font-size: 0.875rem;
}

.clinic-group-meta { font-size: 0.71875rem; color: var(--text-faint); margin-top: 0.15rem; }
.clinic-group-body { padding: 0.25rem 1rem 0.75rem; }

/* Linhas de pessoa */
.person-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.person-row:last-child { border-bottom: none; }
.person-main { display: flex; align-items: center; gap: 0.6rem; min-width: 0; flex: 1; }
.person-name { font-weight: 500; font-size: 0.84375rem; }

.person-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    font-size: 0.71875rem;
    color: var(--text-faint);
    margin-top: 0.15rem;
}

.person-meta .sep { color: var(--border-strong); }
.person-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.person-row--extra { display: none; }
.person-list--all .person-row--extra { display: flex; }
.person-row--hidden { display: none !important; }

.list-search {
    width: 200px;
    max-width: 100%;
    height: 32px;
    padding: 0 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    font-size: 0.78125rem;
    font-family: inherit;
}

.list-search:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(65, 153, 137, 0.12);
}

.list-empty { font-size: 0.78125rem; color: var(--text-faint); padding: 0.7rem 0; }

/* Bloco recolhivel, sem JavaScript */
details.collapse {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 0.7rem;
    background: var(--surface);
}

details.collapse > summary {
    cursor: pointer;
    padding: 0.65rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary-dark);
    list-style: none;
}

details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary::before { content: '\25B8  '; }
details.collapse[open] > summary::before { content: '\25BE  '; }
details.collapse > .collapse-body { padding: 0 0.9rem 0.9rem; }

/* ============================================================
   Receitas vistas pelo paciente
   ============================================================ */

.rx-doctor {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.rx-doctor:last-child { margin-bottom: 0; }

.rx-doctor-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.rx-doctor-name { font-weight: 600; font-size: 0.875rem; }
.rx-item { border-top: 1px solid var(--border); padding-top: 0.7rem; margin-top: 0.7rem; }

.rx-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 0.5rem;
}

.rx-posology { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }

.rx-posology li {
    display: flex;
    gap: 0.6rem;
    font-size: 0.84375rem;
    background: var(--surface-alt);
    border-left: 3px solid var(--primary-light);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
}

.rx-posology .num { color: var(--primary); font-weight: 600; flex-shrink: 0; }
.rx-cancelled .rx-posology li { background: var(--red-soft); border-left-color: #E2B3AD; color: #7A6360; }
.rx-obs { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.5rem; }

.rx-obs strong {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 0.15rem;
}

/* ============================================================
   Area do paciente (blocos herdados)
   ============================================================ */

.patient-hero-card { background: linear-gradient(135deg, #F2F9F7 0%, #E9F5F3 100%); border-color: #CFE7E2; }

.patient-hero-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.patient-hero-inner h2 { margin-bottom: 0; }

.clinic-tag-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.clinic-tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.84375rem;
    font-weight: 500;
}

.clinic-tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.response-list { display: flex; flex-direction: column; gap: 0.6rem; }

.response-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    flex-wrap: wrap;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.response-card:hover { border-color: var(--primary-light); box-shadow: 0 2px 12px rgba(65, 153, 137, 0.1); }
.response-card-info { flex: 1; min-width: 0; }

.response-card-title {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.response-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.71875rem;
    color: var(--text-faint);
    margin-top: 0.3rem;
}

.response-card-meta .sep { color: var(--border-strong); }
.response-card-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* Termo de consentimento / assinatura eletronica */
.terms-box {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: var(--surface-alt);
    margin-bottom: 0.75rem;
}

.terms-accept-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: normal;
    font-size: 0.84375rem;
}

.consent-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.consent-item:last-child { border-bottom: none; }

/* ============================================================
   Formularios de anamnese e prescricao
   ============================================================ */

.field-list { list-style: none; }

.field-list li {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.84375rem;
}

.generated-url {
    background: var(--primary-soft);
    border: 1px solid #C8E4DE;
    padding: 0.9rem;
    border-radius: var(--radius-control);
    word-break: break-all;
    margin: 1rem 0;
    font-size: 0.8125rem;
}

.medication-row { display: flex; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.5rem; }
.medication-row .form-group { margin-bottom: 0; }

.anamnesis-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.anamnesis-accordion { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.accordion-item + .accordion-item { border-top: 1px solid var(--border); }

.accordion-trigger {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: background var(--transition);
}

.accordion-trigger:hover { background: var(--surface-alt); }
.accordion-trigger[aria-expanded="true"] { background: var(--primary-soft); }
.accordion-title { display: flex; align-items: center; gap: 0.5rem; }
.accordion-meta { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.accordion-chevron { transition: transform 0.2s; color: var(--text-faint); }
.accordion-body { border-top: 1px solid var(--border); background: var(--surface-alt); }
.anamnesis-answer-list { list-style: none; }

.answer-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.6rem 1rem;
    font-size: 0.84375rem;
    border-bottom: 1px solid var(--border);
}

.answer-item:last-child { border-bottom: none; }
.answer-label { color: var(--text-muted); flex: 1; min-width: 0; font-weight: 500; font-size: 0.78125rem; }

.answer-value {
    font-weight: 500;
    color: var(--text);
    text-align: right;
    max-width: 55%;
    word-break: break-word;
}

.answer-negative { color: var(--text-faint); font-weight: 400; }

.medication-list { list-style: none; }

.medication-item {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    margin-bottom: 0.5rem;
    background: var(--surface-alt);
}

.medication-number { font-weight: 700; color: var(--primary); flex-shrink: 0; font-size: 0.875rem; }
.medication-text { font-size: 0.875rem; color: var(--text); line-height: 1.5; }

.prescription-obs {
    margin-top: 1.25rem;
    padding: 0.85rem 1rem;
    background: var(--surface-alt);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
}

.prescription-obs strong {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.prescription-obs p { font-size: 0.84375rem; color: var(--text-muted); }

/* ============================================================
   Cartoes de numero herdados (.stats)
   ============================================================ */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1rem;
    text-align: center;
}

.stat-card .number { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
a.stat-card { display: block; text-decoration: none; color: inherit; transition: border-color var(--transition); }
a.stat-card:hover { border-color: var(--primary-light); text-decoration: none; }

/* ============================================================
   Telas sem menu: login, cadastro e convite
   ============================================================ */

.minimal-body { background: var(--bg); }

.minimal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
}

.minimal-page {
    min-height: calc(100vh - var(--topbar-h));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.minimal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 4px 24px rgba(16, 24, 40, 0.06);
}

.minimal-card h1 { font-size: 1.375rem; margin-bottom: 0.35rem; color: var(--text); }
.minimal-card p.sub { color: var(--text-muted); font-size: 0.84375rem; margin-bottom: 1.5rem; }

/* ============================================================
   Utilitarios
   ============================================================ */

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); font-size: 0.84375rem; }

/* ============================================================
   Responsivo
   ============================================================ */

@media (max-width: 1024px) {
    .panel-grid { grid-template-columns: 1fr; }

    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
    .app-main { margin-left: 0; }
    .topbar-menu { display: flex; }

    .app-shell--drawer .app-sidebar { transform: translateX(0); }

    .app-shell--drawer .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(31, 42, 55, 0.35);
        z-index: 55;
    }

    /* O recolhimento so vale no desktop */
    .app-shell--collapsed .app-sidebar { width: var(--sidebar-w); }
    .app-shell--collapsed .app-main { margin-left: 0; }
    .app-shell--collapsed .app-logo { max-width: 130px; }
    .app-shell--collapsed .sidebar-brand { padding: 0 0.9rem 0 1rem; justify-content: space-between; }
    .app-shell--collapsed .sidebar-user { justify-content: flex-start; padding: 0.6rem; }
    .app-shell--collapsed .sidebar-user-info,
    .app-shell--collapsed .sidebar-clinic,
    .app-shell--collapsed .nav-item-label,
    .app-shell--collapsed .nav-dot,
    .app-shell--collapsed .soon-chip,
    .app-shell--collapsed .nav-section-label { display: initial; }
    .app-shell--collapsed .sidebar-clinic { display: block; }
    .app-shell--collapsed .nav-item { justify-content: flex-start; padding: 0.5rem 0.6rem; }
    .app-shell--collapsed .nav-item-label { flex: 1; min-width: 0; }
}

@media (max-width: 760px) {
    .app-content { padding: 1rem; }
    .app-topbar { padding: 0 1rem; gap: 0.6rem; }
    .topbar-search { max-width: none; }
    .page-title { font-size: 1.1875rem; }
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .metric-card { padding: 0.85rem; }
    .metric-icon { width: 32px; height: 32px; margin-bottom: 0.6rem; }
    .metric-value { font-size: 1.375rem; }
    .form-row { grid-template-columns: 1fr; }
    .response-card-actions { width: 100%; justify-content: flex-end; }
    .person-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 420px) {
    .metric-grid { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
}
