:root {
    --samu-red: #c20d2f;
    --samu-red-dark: #9a0a25;
    --samu-blue: #004b82;
    --samu-yellow: #ecb32a;
    --samu-orange: #f58000;
    --samu-gray: #929292;
    --samu-gray-dark: #5c5c5c;
    --samu-bg: #eef1f4;
    --samu-panel: #f7f8fa;
    --samu-white: #ffffff;
    --samu-border: #d5dbe3;
    --samu-shadow: 0 10px 30px rgba(0, 43, 82, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    list-style: none;
}

html {
    overflow-y: scroll;
    overflow-x: auto;
    height: auto;
    max-height: none;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 13px;
    color: var(--samu-gray-dark);
    background:
        radial-gradient(circle at top left, rgba(194, 13, 47, 0.05), transparent 28%),
        radial-gradient(circle at top right, rgba(0, 75, 130, 0.06), transparent 24%),
        var(--samu-bg);
    overflow: visible;
    overflow-x: auto;
    height: auto;
    min-height: 100%;
    max-height: none;
    position: relative;
    touch-action: pan-y pinch-zoom;
}

.clearfix::after {
    content: "";
    display: block;
    clear: both;
}

.app-shell,
.conteiner {
    width: min(1320px, 100%);
    margin: 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: var(--samu-white);
    box-shadow: var(--samu-shadow);
    padding-bottom: 24px;
}

.faixa {
    width: 100%;
    height: 20px;
    background: url('../img/faixa-brasil.png') no-repeat right center var(--samu-blue);
    background-size: auto 20px;
    border-bottom: 2px solid var(--samu-yellow);
}

.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px 24px 10px;
    border-bottom: 1px solid var(--samu-border);
    background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
}

.header--compact {
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 14px;
    min-height: 68px;
    align-items: center;
}

.header--compact .header-logo {
    flex: 0 0 auto;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
}

.header--compact .logo-saude-digital {
    display: block;
    height: 54px;
    width: auto;
    max-width: 240px;
    margin: 0 auto;
    object-fit: contain;
}

.header--compact .lbl-sistema {
    display: block;
    width: 100%;
    margin-top: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #0d3b5e;
    line-height: 1.15;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    flex-shrink: 0;
}

.header--compact .data-hora {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    text-align: right;
}

.header--compact .administrador {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    text-align: right;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header--compact .user-name {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header--compact .sys-links {
    margin: 0;
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.header--compact .sys-links a {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f3f5f8;
}

.header--compact .sys-links a:hover {
    background: #fdecee;
    text-decoration: none;
}

.header-logo {
    flex: 0 0 auto;
}

.logo-saude-digital {
    height: 58px;
    width: auto;
    max-width: 260px;
    object-fit: contain;
    display: block;
}

.header .localidade {
    flex: 1 1 220px;
    min-height: 42px;
    padding-right: 48px;
    background: url('../img/sus.png') no-repeat right center;
    color: #9aa3ad;
    text-transform: uppercase;
}

.header .localidade p {
    font-size: 11px;
    letter-spacing: 0.08em;
}

.lbl-localidade {
    font-size: 17px;
    font-weight: 600;
    color: #8d97a1;
}

.header .data-hora {
    text-align: right;
    min-width: 110px;
}

.header:not(.header--compact) .horario {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--samu-red);
    line-height: 1.1;
}

.header:not(.header--compact) .data {
    font-size: 12px;
    color: var(--samu-gray);
}

.header.header--compact .data-hora .horario,
.header.header--compact .data-hora .data {
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--samu-red);
    line-height: 1.2;
    display: inline;
}

.header.header--compact .user-name {
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: #334155;
    line-height: 1.2;
}

.header .administrador {
    margin-left: auto;
    text-align: right;
    color: var(--samu-orange);
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    color: #334155;
}

.user-meta {
    font-size: 11px;
    color: #8a94a1;
    margin: 2px 0 4px;
}

.sys-links {
    margin-top: 4px;
    font-weight: 400;
}

.sys-links a {
    color: var(--samu-red);
    text-decoration: none;
    font-size: 12px;
}

.sys-links a:hover {
    text-decoration: underline;
}

.header .versao {
    width: 100%;
    text-align: right;
    font-size: 11px;
    color: #9aa3ad;
}

.content,
.app-main {
    display: block;
    padding: 20px 24px 28px;
    overflow: visible;
    height: auto;
}

.app-main--compact {
    padding: 8px 12px 12px;
}

.menu-top {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.menu-top--compact {
    margin-bottom: 8px;
    gap: 6px;
}

.menu-top--compact .aba {
    padding: 5px 12px;
    font-size: 12px;
}

.aba {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 999px;
    background: #edf1f5;
    color: var(--samu-gray-dark);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 600;
}

.aba.active,
.aba:hover {
    background: var(--samu-red);
    color: #fff;
    box-shadow: 0 8px 18px rgba(194, 13, 47, 0.18);
}

.page-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.page-title {
    color: var(--samu-red);
    font-size: 28px;
    line-height: 1.1;
    margin-bottom: 6px;
}

.page-subtitle {
    color: #6d7885;
    font-size: 14px;
}

.hero-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-card {
    min-width: 150px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #fff, #f3f6f9);
    border: 1px solid var(--samu-border);
}

.stat-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a94a1;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--samu-blue);
}

.panel,
.gravacoes-panel {
    background: var(--samu-panel);
    border: 1px solid var(--samu-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--samu-shadow);
    overflow: visible;
}

.rows .titulo {
    color: var(--samu-red);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.box-interno {
    background: var(--samu-white);
    border: 1px solid var(--samu-border);
    border-radius: var(--radius-sm);
    padding: 20px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.box-interno.grande {
    min-height: 120px;
}

.toolbar {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

.toolbar-section {
    background: var(--samu-white);
    border: 1px solid var(--samu-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.section-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8a94a1;
    margin-bottom: 10px;
    font-weight: 700;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(194, 13, 47, 0.18);
    background: linear-gradient(180deg, #fff, #fff4f6);
    color: var(--samu-red);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tool-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(194, 13, 47, 0.12);
}

.tool-btn--secondary {
    background: linear-gradient(180deg, #fff, #f3f6fa);
    color: var(--samu-blue);
    border-color: rgba(0, 75, 130, 0.16);
}

.tool-btn:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.tool-icon {
    font-size: 14px;
    line-height: 1;
}

.search-form {
    display: grid;
    gap: 14px;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 170px;
}

.field--grow {
    flex: 1 1 220px;
}

.field span {
    font-size: 12px;
    font-weight: 600;
    color: #667281;
}

.field input,
.search-form input,
.form-grid input,
.form-inline input,
.form-inline select,
.login-form input,
.table-input,
.table-select,
.field-select {
    height: 40px;
    border: 1px solid var(--samu-border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13px;
    background: #fbfcfd;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.table-input,
.table-select {
    width: 100%;
    min-width: 140px;
    height: 36px;
}

.field-select,
.table-select {
    padding-right: 28px;
}

.admin-panel {
    display: grid;
    gap: 16px;
}

.admin-create-card {
    margin-bottom: 0;
}

.admin-create-form,
.password-form {
    display: block;
}

.field-row--stack {
    align-items: stretch;
}

.admin-table-wrap {
    margin-top: 0;
}

.admin-users-table .col-cpf {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
}

.current-user-row {
    background: #fff8eb !important;
}

.badge-active {
    background: #eaf7ef;
    color: #2f7b45;
}

.badge-inactive {
    background: #fdecec;
    color: #a12626;
}

.badge-provisional {
    background: #fff4df;
    color: #9a6110;
}

.badge-defined {
    background: #eef2ff;
    color: #4253b6;
}

.admin-row-actions {
    display: inline-block;
    margin-right: 4px;
}

.action-btn--save {
    background: #eef5fb;
    color: var(--samu-blue);
}

.action-btn--reset {
    background: #fff4df;
    color: #9a6110;
}

.action-btn--toggle {
    background: #fdecec;
    color: #a12626;
}

.status-box a {
    color: inherit;
    font-weight: 700;
}

.field input:focus,
.login-form input:focus {
    outline: none;
    border-color: rgba(194, 13, 47, 0.45);
    box-shadow: 0 0 0 4px rgba(194, 13, 47, 0.08);
}

.field-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--samu-orange);
}

.field-hint--muted {
    color: #7b8794;
}

.bulk-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #fff7ea, #fffdf8);
    border: 1px solid #ecd7a8;
    box-shadow: 0 8px 18px rgba(154, 97, 16, 0.08);
}

.bulk-bar-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bulk-badge {
    display: inline-block;
    width: fit-content;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fff4df;
    color: #9a6110;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.botao {
    min-height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(180deg, #d2183a, var(--samu-red));
    color: #fff;
    box-shadow: 0 10px 20px rgba(194, 13, 47, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--samu-red), var(--samu-red-dark));
}

.btn-secondary {
    background: var(--samu-gray);
    color: #fff;
}

.btn-search {
    min-width: 130px;
}

.status-box {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--samu-border);
    background: #fff;
}

.status-box--info {
    background: #f5f9ff;
    border-color: #d7e6f5;
    color: #48627d;
}

.status-box--success {
    background: #f2fbf4;
    border-color: #cfe8d4;
    color: #2f6b3b;
}

.status-box--error {
    background: #fff5f6;
    border-color: #f1ccd3;
    color: #9f1f35;
}

.status-box--loading {
    background: #fffaf2;
    border-color: #f1dfbf;
    color: #8a6118;
}

.status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 75, 130, 0.08);
    font-weight: 700;
}

.player-bar {
    margin-top: 14px;
    background: linear-gradient(135deg, #10243a, #183a5d);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    color: #fff;
    box-shadow: 0 12px 24px rgba(16, 36, 58, 0.22);
}

.player-info {
    min-width: 220px;
}

.player-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.player-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.player-bar audio {
    flex: 1 1 320px;
    min-width: 260px;
    height: 42px;
}

.table-wrap {
    background: #fff;
    border: 1px solid var(--samu-border);
    border-radius: var(--radius-sm);
}

.gravacoes-panel > .table-wrap {
    --results-height: clamp(190px, calc((100vh - 240px) * 0.593), 427px);
    height: var(--results-height);
    min-height: var(--results-height);
    max-height: var(--results-height);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.admin-panel .admin-table-wrap {
    max-height: clamp(173px, calc((100vh - 240px) * 0.539), 388px);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Layout compacto - gravações */
.gravacoes-panel--compact {
    padding: 10px;
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.search-form--compact {
    margin-bottom: 8px;
}

.search-grid {
    display: grid;
    grid-template-columns: 170px 170px 110px 110px minmax(120px, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.search-form--compact .field span {
    font-size: 10px;
    font-weight: 700;
    color: #7b8794;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-form--compact .field input {
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
    min-width: 0;
}

.search-form--compact .field--date {
    min-width: 0;
}

.search-form--compact .field--sm {
    min-width: 0;
}

.search-form--compact .field--grow {
    min-width: 0;
}

.search-form--compact .btn-search {
    min-width: 88px;
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.search-meta {
    margin-top: 6px;
    font-size: 11px;
    color: #8a94a1;
    line-height: 1.3;
}

.status-box--compact {
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
}

.status-box--compact .status-icon {
    display: none;
}

.results-table--compact th,
.results-table--compact td {
    padding: 6px 8px;
    font-size: 11px;
}

.results-table--compact .badge {
    padding: 2px 7px;
    font-size: 10px;
}

.results-table--compact .duration-pill {
    min-width: 34px;
    padding: 2px 6px;
    font-size: 10px;
}

.results-table--compact .action-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.empty-state--compact {
    padding: 18px 12px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state--compact strong {
    font-size: 12px;
}

.bulk-bar--compact {
    margin-top: 8px;
    padding: 8px 12px;
    gap: 10px;
}

.bulk-bar--compact .bulk-badge {
    display: none;
}

.player-bar--compact {
    margin-top: 8px;
    padding: 8px 12px;
    gap: 10px;
}

.player-bar--compact .player-badge {
    display: none;
}

.player-bar--compact .player-label {
    font-size: 12px;
    min-width: 180px;
    flex: 0 1 40%;
}

.player-bar--compact audio {
    height: 32px;
    min-width: 200px;
}

.btn-compact {
    min-height: 30px;
    padding: 0 12px;
    font-size: 12px;
}

.footer {
    border-top: 2px solid var(--samu-red);
    padding: 8px 14px;
    color: var(--samu-gray);
    font-size: 10px;
    background: #fafbfc;
}

@media (max-width: 1100px) {
    .search-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

    .search-form--compact .btn-search {
        grid-column: 1 / -1;
        width: 100%;
    }

    .header--compact {
        flex-wrap: wrap;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 900px) {
    .search-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #7f8791, var(--samu-gray));
    color: #fff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 10px;
    text-align: left;
}

.results-table td {
    padding: 11px 10px;
    border-bottom: 1px solid #edf1f5;
    vertical-align: middle;
}

.results-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.results-table tbody tr:hover,
.results-table tbody tr.selected {
    background: #fff1f4;
}

.col-select {
    width: 42px;
    text-align: center;
}

.col-duration,
.col-actions {
    width: 90px;
    text-align: center;
}

.col-datetime {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.col-arquivo {
    max-width: 280px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11px;
    color: #4a5560;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.results-table--compact .col-arquivo {
    max-width: 220px;
    font-size: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.badge-type {
    background: #eef2ff;
    color: #4253b6;
}

.badge-source {
    background: #fff4df;
    color: #9a6110;
}

.badge-dest {
    background: #eaf7ef;
    color: #2f7b45;
}

.duration-pill {
    display: inline-flex;
    min-width: 42px;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 999px;
    background: #edf1f5;
    font-weight: 700;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #fff1f4;
    color: var(--samu-red);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.action-btn--download {
    background: #eef5fb;
    color: var(--samu-blue);
}

.action-btn:hover {
    transform: translateY(-1px);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 36px 20px;
    color: #7b8794;
    text-align: center;
}

.empty-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.loading-row {
    text-align: center;
    padding: 28px;
    color: #7b8794;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d7dde5;
    border-top-color: var(--samu-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.av_erro { color: var(--samu-red); margin-bottom: 10px; }
.av_sucesso { color: #2d7a2d; margin-bottom: 10px; }
.av_alerta { color: var(--samu-orange); margin-bottom: 10px; font-weight: 700; }

.login-page .login-content {
    display: flex;
    justify-content: center;
    padding: 36px 0 48px;
}

.login-panel {
    width: min(460px, 100%);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    width: 100%;
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    right: 6px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #667281;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.toggle-password:hover {
    background: #eef1f5;
    color: var(--samu-red);
}

.toggle-password:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(194, 13, 47, 0.12);
}

.lb-top {
    font-weight: 700;
    color: #667281;
}

.form-grid {
    display: grid;
    gap: 12px;
    max-width: 460px;
}

.form-grid label {
    font-weight: 700;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

.inline-form {
    display: inline-block;
    margin-right: 6px;
}

.hint {
    margin-top: 10px;
    color: #7b8794;
    font-size: 12px;
}

h3 {
    color: var(--samu-gray);
    font-size: 14px;
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .header {
        padding: 14px 16px 10px;
    }

    .content {
        padding: 16px;
    }

    .page-hero {
        flex-direction: column;
    }

    .header .administrador {
        margin-left: 0;
        width: 100%;
        text-align: left;
    }

    .field,
    .btn-search {
        width: 100%;
    }
}
