/* ============================================================
   APR/PT — visual "moderno e limpo"
   Tokens + componentes. Não renomear classes usadas no app.js.
   ============================================================ */

:root {
    --brand: #0d3b66;
    --brand-2: #17548f;
    --brand-3: #2a72c4;
    --brand-soft: #eaf2fb;
    --bg: #eef1f6;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #4a5768;
    --line: #dde5ee;
    --line-strong: #c3cedb;
    --danger: #b42318;
    --ok: #166534;
    --warn: #92400e;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, .06);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .14);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);
    --ring: 0 0 0 3px rgba(23, 84, 143, .22);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.req { color: var(--danger); font-weight: 700; }
h1, h2, h3 { color: #0b1220; letter-spacing: -.01em; }

/* Spinner de carregamento */
.loading {
    display: flex; align-items: center; gap: 9px;
    color: var(--muted); font-size: 14px; font-weight: 500;
}
.loading::before {
    content: ""; width: 15px; height: 15px; flex: none;
    border: 2px solid var(--line-strong); border-top-color: var(--brand-3);
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Marca ──────────────────────────────────────────────── */
.brand-mark {
    display: inline-grid; place-items: center; flex: none;
    background: #fff; border-radius: 12px; padding: 6px;
    box-shadow: 0 6px 16px rgba(13, 59, 102, .32);
}
.brand-mark img { display: block; max-width: 100%; max-height: 100%; }

/* ── Login ──────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(900px 520px at 12% -12%, rgba(42, 114, 196, .38), transparent 62%),
        radial-gradient(700px 500px at 108% 112%, rgba(23, 84, 143, .35), transparent 60%),
        linear-gradient(158deg, #10456f 0%, #0d3b66 48%, #082740 100%);
}
.card {
    background: var(--card); border-radius: 18px; padding: 30px 28px;
    box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .5);
    width: 100%; max-width: 410px;
    animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-head .brand-mark { width: 78px; height: 46px; }
.login-head h1 { font-size: 22px; margin: 0; }
.login-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.login-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); }
.login-foot {
    margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--muted);
    border-top: 1px solid var(--line); padding-top: 14px;
}
h1 { font-size: 21px; margin: 0; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: linear-gradient(180deg, #0e4069 0%, #0b3157 100%);
    color: #fff; display: flex; align-items: center; gap: 18px;
    padding: 0 18px; min-height: 62px; flex-wrap: wrap;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .22);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand {
    display: inline-flex; align-items: center; gap: 11px;
    color: #fff; text-decoration: none; font-weight: 700;
    font-size: 16px; letter-spacing: .02em;
}
.brand-nwt {
    display: block; height: 22px; width: auto; flex: none;
    background: #fff; border-radius: 6px; padding: 4px 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.nav { display: flex; gap: 5px; flex: 1; flex-wrap: wrap; }
.nav a {
    color: #cfe0f5; text-decoration: none; padding: 8px 13px;
    border-radius: 9px; font-size: 14px; font-weight: 500;
    border: 1px solid transparent; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.nav a.active {
    background: #fff; color: var(--brand); font-weight: 700;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
}
.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #eaf2fb; }
.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-3), var(--brand-2));
    color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .03em;
    border: 2px solid rgba(255, 255, 255, .35);
}
#user-info { white-space: nowrap; }
.content { padding: 26px 22px 40px; max-width: 1180px; margin: 0 auto; }

/* ── Cabeçalho de página / ferramentas ──────────────────── */
.page-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head h1 { font-size: 23px; margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar > input, .toolbar > select { width: auto; flex: 0 1 auto; min-width: 130px; }

/* ── Filtros ────────────────────────────────────────────── */
.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px; margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}
.filters input, .filters select { margin: 0; width: auto; flex: 1 1 190px; }

/* ── Formulários ────────────────────────────────────────── */
label { display: block; margin-bottom: 13px; font-size: 13.5px; font-weight: 600; color: #1e293b; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }

input, textarea {
    width: 100%; padding: 9px 12px; margin-top: 5px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
select {
    width: 100%; padding: 9px 32px 9px 12px; margin-top: 5px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit; background-color: #fff; color: var(--text);
    appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5 10 4.5' fill='none' stroke='%234a5768' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand-3); box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled {
    background: #f2f5f9; color: #56637a; border-color: var(--line);
    cursor: not-allowed; -webkit-text-fill-color: #56637a; opacity: 1;
}
input::placeholder, textarea::placeholder { color: #93a0b1; }
label.inline input, label.inline select { width: auto; margin: 0; }
input[type="checkbox"], input[type="radio"] {
    width: 17px; height: 17px; margin: 0; padding: 0; accent-color: var(--brand-3);
    cursor: pointer; flex: none;
}
input[type="checkbox"]:disabled, input[type="radio"]:disabled { cursor: not-allowed; }
textarea { min-height: 74px; resize: vertical; line-height: 1.5; }

/* ── Botões ─────────────────────────────────────────────── */
button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--brand); color: #fff; border: 1px solid transparent;
    border-radius: var(--radius-sm); padding: 9px 16px;
    font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
}
button:hover { background: var(--brand-2); box-shadow: 0 4px 12px rgba(13, 59, 102, .22); }
button:active { transform: translateY(1px); box-shadow: none; }
button:focus-visible { outline: 2px solid var(--brand-3); outline-offset: 2px; box-shadow: none; }
button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
button.secondary { background: #fff; color: #1e293b; border-color: var(--line-strong); }
button.secondary:hover { background: #f3f6fa; box-shadow: var(--shadow-xs); }
button.small { padding: 6px 11px; font-size: 13px; }
button.link {
    background: none; color: var(--brand-2); padding: 3px 5px;
    font-weight: 600; font-size: 13.5px; border-radius: 6px;
}
button.link:hover { background: var(--brand-soft); box-shadow: none; text-decoration: underline; }
button.link.danger { color: var(--danger); }
button.link.danger:hover { background: #fdecec; }
.icon-btn { background: none; border-color: transparent; color: var(--muted); font-size: 26px; line-height: 1; padding: 2px 8px; }
.icon-btn:hover { background: #f1f4f8; color: var(--text); box-shadow: none; }
.btn-link {
    display: inline-flex; align-items: center; height: 38px; padding: 0 16px;
    background: var(--brand); color: #fff; text-decoration: none;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    transition: background .15s, box-shadow .15s;
}
.btn-link:hover { background: var(--brand-2); box-shadow: 0 4px 12px rgba(13, 59, 102, .22); }
#form-login button[type="submit"] { width: 100%; margin-top: 4px; padding: 11px 16px; }

/* ── Tabelas ────────────────────────────────────────────── */
.grid {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-xs); font-variant-numeric: tabular-nums;
}
.grid th, .grid td {
    text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line);
    font-size: 14px; vertical-align: top; color: var(--text);
}
.grid th {
    background: #f2f5f9; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .6px; color: #45526a; font-weight: 700;
    border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover td { background: #f5f9fe; }
.grid tbody tr:nth-child(even) td { background: #fbfcfe; }
.grid tbody tr:nth-child(even):hover td { background: #f2f7fd; }
.grid td.acoes { white-space: nowrap; }
#os-body, #d-body, #u-body, #modelo-body, .table-wrap { overflow-x: auto; }
.grid.compact th, .grid.compact td { padding: 7px 9px; font-size: 13px; }
.grid.compact select,
.grid.compact input[type="text"],
.grid.compact input[type="number"],
.grid.compact input[type="search"] { margin: 0; padding: 6px 8px; font-size: 13px; }
.grid.compact select { padding-right: 26px; }
.grid.compact input[type="checkbox"],
.grid.compact input[type="radio"] { margin: 0; padding: 0; }
.table-wrap { margin-top: 6px; }

/* Grupos de status na lista de APR/PT (ordem de trabalho) */
#d-body .grid tr.linha-grupo td {
    background: #eaf2fb; color: var(--brand); font-weight: 700;
    font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
    padding: 8px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}

/* ── Tags / status ──────────────────────────────────────── */
.tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 999px; font-size: 12px;
    font-weight: 600; line-height: 1.45; border: 1px solid transparent;
    white-space: nowrap;
}
.tag::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .8; flex: none;
}
.tag.role-tecnico { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.tag.role-supervisor { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.tag.role-admin { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.tag-rascunho { background: #e9eef5; color: #40506a; border-color: #d5ddea; }
.tag-aguardando_aprovacao { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.tag-liberada { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.tag-em_execucao { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.tag-encerrada { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.tag-cancelada { background: #fdecec; color: #b42318; border-color: #fecaca; }

/* ── Modal ──────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; background: rgba(11, 23, 42, .62);
    backdrop-filter: blur(3px); display: grid; place-items: center;
    padding: 16px; z-index: 50; animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
    background: #fff; border-radius: 16px; width: 100%; max-width: 500px;
    max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg);
    animation: pop .2s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-box header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 18px; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; background: #fff; z-index: 1;
    border-radius: 16px 16px 0 0;
}
.modal-box header h2 { font-size: 16.5px; margin: 0; }
.modal-box > div { padding: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: #0f1d33; color: #fff; padding: 12px 20px;
    border-radius: 999px; font-size: 14px; font-weight: 500;
    box-shadow: var(--shadow-md); z-index: 60; max-width: 92vw;
    border: 1px solid rgba(255, 255, 255, .12);
    animation: rise .22s ease both;
}
.toast.error { background: var(--danger); border-color: rgba(255, 255, 255, .18); }

/* ── Banner de atualização do APK ───────────────────────── */
.apk-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--brand-soft); border: 1px solid #bcd6f2; border-left: 4px solid var(--brand-3);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
    box-shadow: var(--shadow-xs); animation: rise .25s ease both;
}
.apk-banner-txt { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.apk-banner-txt strong { color: var(--brand); font-size: 14.5px; font-weight: 600; }
.apk-banner-acoes { display: flex; gap: 8px; align-items: center; }
.apk-banner-acoes .btn-link { height: 36px; padding: 0 16px; font-size: 13.5px; }
.apk-banner-acoes button.secondary { height: 36px; padding: 0 14px; font-size: 13.5px; }
@media (max-width: 480px) {
    .apk-banner { flex-direction: column; align-items: flex-start; }
    .apk-banner-acoes { width: 100%; }
    .apk-banner-acoes .btn-link, .apk-banner-acoes button.secondary { flex: 1 1 auto; text-align: center; }
}

/* ── Barra do modo offline ──────────────────────────────── */
.offline-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    background: #fff7ed; border: 1px solid #fed7aa; border-left: 4px solid #d97706;
    color: #7c2d12; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
    font-size: 13.5px; box-shadow: var(--shadow-xs);
}
.offline-bar button { flex: none; }

/* ── Estados vazios / carregando ────────────────────────── */
#login-error:empty { display: none; }
#os-body > p, #d-body > p, #u-body > p, #modelo-body > p, #content > p.loading, #content > p.error {
    text-align: center; padding: 26px 16px; color: var(--muted);
}
#content > p.error { color: var(--danger); font-weight: 600; }
.empty-state { text-align: center; color: var(--muted); padding: 34px 16px; }

/* ── Documento APR/PT ───────────────────────────────────── */
.panel {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}
.panel h2 {
    display: flex; align-items: center; gap: 11px;
    font-size: 15px; margin: 0 0 16px; color: var(--text);
    border-bottom: 1px solid var(--line); padding-bottom: 14px;
    font-weight: 700; letter-spacing: .01em;
}
.step {
    display: inline-grid; place-items: center; flex: none;
    width: 27px; height: 27px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-3), var(--brand));
    color: #fff; font-size: 13.5px; font-weight: 700;
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.grid2 .label { display: block; margin-bottom: 4px; }
.grid2 > div > div { font-size: 14.5px; color: var(--text); line-height: 1.5; word-break: break-word; }
.grid2 > div > div img {
    max-height: 56px; background: #fff; padding: 3px 6px;
    border: 1px solid var(--line); border-radius: 8px;
}
.label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px;
    color: #56637a; font-weight: 700;
}
.field { margin: 18px 0 0; }
.chips, .checks { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px; margin: 0;
    border: 1px solid var(--line-strong); border-radius: 999px;
    padding: 7px 13px; font-size: 13px; background: #fff; color: var(--text);
    font-weight: 500; cursor: pointer; user-select: none;
    transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--brand-3); background: var(--brand-soft); }
.chip:has(input:checked) {
    background: var(--brand); border-color: var(--brand);
    color: #fff; font-weight: 600;
}
.chip:has(input:checked):hover { background: var(--brand-2); border-color: var(--brand-2); }
.chip:has(input:disabled) { cursor: not-allowed; opacity: .85; }
.chip:has(input[value="AUTORIZADA"]:checked) { background: #dcfce7; border-color: #86efac; color: #14532d; }
.chip:has(input[value="NAO_AUTORIZADA"]:checked) { background: #fdecec; border-color: #fca5a5; color: #b42318; }
.chip:has(input[value="CONCLUIDO"]:checked) { background: #dcfce7; border-color: #86efac; color: #14532d; }
.chip:has(input[value="SUSPENSO"]:checked) { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.chip:has(input[value="sim"]:checked) { background: #dcfce7; border-color: #86efac; color: #14532d; }
.chip:has(input[value="nao"]:checked) { background: #fdecec; border-color: #fca5a5; color: #b42318; }
.chip:has(input[value="na"]:checked) { background: #e9eef5; border-color: #c3cedb; color: #40506a; }

.check-item {
    display: flex; justify-content: space-between; gap: 12px; align-items: center;
    padding: 10px 2px; border-bottom: 1px dashed var(--line); flex-wrap: wrap;
    font-size: 14px;
}
.check-item:last-child { border-bottom: 0; }
.check-item .chips { margin: 0; }

.termo {
    background: #f3f7fb; border-left: 4px solid var(--brand-3);
    padding: 13px 15px; font-size: 13px; color: #26364d;
    margin-top: 16px; border-radius: 0 8px 8px 0; line-height: 1.55;
}
.termo strong { color: var(--brand); }

.sticky-actions {
    position: sticky; bottom: 0; z-index: 20;
    background: rgba(238, 241, 246, .93); backdrop-filter: blur(8px);
    padding: 14px 16px; margin: 4px -8px 0;
    display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
    border-top: 1px solid var(--line-strong);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -8px 22px rgba(15, 23, 42, .07);
}
.assinatura { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.assinatura img { height: 70px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.sig-canvas {
    width: 100%; height: 200px; border: 2px dashed var(--line-strong);
    border-radius: 12px; touch-action: none; display: block;
    background:
        linear-gradient(transparent 82%, rgba(13, 59, 102, .16) 82%, rgba(13, 59, 102, .16) 83%, transparent 83%),
        #fff;
}
.sig-canvas:hover { border-color: var(--brand-3); }

/* ── Cabeçalho da empresa + grupos de risco ─────────────── */
.empresa {
    border-bottom: 2px solid var(--line); padding-bottom: 10px; margin-bottom: 16px;
}
.empresa strong { display: block; font-size: 15.5px; color: var(--brand); }
.empresa small { display: block; color: var(--muted); font-size: 13px; }
.grupo-risco {
    margin-top: 18px; font-weight: 700; color: var(--brand);
    text-transform: uppercase; font-size: 11.5px; letter-spacing: .8px;
    display: flex; align-items: center; gap: 9px;
}
.grupo-risco::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rk-nivel {
    font-size: 12.5px; font-weight: 700; text-align: center;
    vertical-align: middle; white-space: nowrap;
}
.rk-nivel::after {
    content: ""; display: inline-block; width: 7px; height: 7px;
    border-radius: 50%; background: currentColor; margin-left: 7px; vertical-align: 1px;
}
.rk-nivel.lvl-none { color: #93a0b1; }
.rk-nivel.lvl-baixo { color: #15803d; }
.rk-nivel.lvl-medio { color: #b45309; }
.rk-nivel.lvl-alto { color: #c2410c; }
.rk-nivel.lvl-critico { color: #b42318; }
.rk-nivel.lvl-critico::after { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ── Resumo (chips de status) ───────────────────────────── */
.resumo { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
    border-radius: 999px; padding: 7px 15px; font-size: 13px;
    font-weight: 600; cursor: pointer;
    transition: transform .12s, box-shadow .15s, filter .15s;
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); filter: brightness(.97); }
.stat strong { font-weight: 800; }
.stat.total { background: var(--brand); color: #fff; }

/* ── Abas ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
    background: #fff; color: #33415a; border: 1px solid var(--line-strong);
    border-radius: 999px; padding: 8px 17px; font-size: 14px; font-weight: 600;
    transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { background: var(--brand-soft); border-color: var(--brand-3); color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 4px 12px rgba(13, 59, 102, .2); }

/* ── PT ─────────────────────────────────────────────────── */
.pt-status { margin-top: 18px; }
.pt-status .chips { margin-top: 7px; }

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 760px) {
    .content { padding: 16px 12px 32px; }
    .page-head h1 { font-size: 20px; }
    #user-info { display: none; }
    .grid2 { grid-template-columns: 1fr; }
    .panel { padding: 17px 15px; }
    .topbar { padding: 8px 12px; gap: 10px; }
    /* Cabeçalho em uma única linha: escudo + navegação + usuário */
    .topbar { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; min-height: 52px; }
    .brand > span { display: none; } /* texto "APR/PT" sai no celular; a logo NWT fica */
    .brand-nwt { height: 18px; padding: 3px 6px; }
    .nav { order: 0; width: auto; flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; padding: 6px 10px; font-size: 13px; }
    .user-box { flex: none; gap: 8px; }
    #user-avatar { width: 28px; height: 28px; font-size: 11px; }
    #btn-logout { padding: 5px 10px; font-size: 12.5px; }
    .grid { min-width: 620px; }
    .sticky-actions { margin: 4px -6px 0; }
    .sticky-actions button, .sticky-actions .btn-link { flex: 1 1 auto; }
    .modal-box { max-height: 94vh; }
    .sig-canvas { height: 170px; }

    /* Listas de OS e APR/PT: cartões compactos (sem rolagem lateral) */
    #os-body, #d-body { overflow-x: visible; }
    #os-body .grid, #d-body .grid { min-width: 0; width: 100%; }
    #os-body .grid thead, #d-body .grid thead { display: none; }
    #os-body .grid tbody, #d-body .grid tbody { display: block; }
    #os-body .grid tr.linha-os, #d-body .grid tr.linha-doc {
        display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px;
        background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand-3);
        border-radius: 12px; padding: 10px 12px; margin: 0 0 9px;
        box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    }
    #os-body .grid tr.linha-os:active, #d-body .grid tr.linha-doc:active { background: #f2f7fd; }
    #os-body .grid tr.linha-os td, #d-body .grid tr.linha-doc td { display: block; border: 0; padding: 0; background: transparent; }
    #os-body .grid tbody tr:nth-child(even) td, #d-body .grid tbody tr:nth-child(even) td,
    #os-body .grid tbody tr:hover td, #d-body .grid tbody tr:hover td { background: transparent; }

    /* Cartão da OS */
    #os-body .grid td.c-hora { order: 1; font-weight: 700; color: var(--brand); }
    #os-body .grid td.c-status { order: 2; margin-left: auto; }
    #os-body .grid td.c-cliente { order: 3; flex: 1 1 100%; font-weight: 600; font-size: 14.5px; line-height: 1.3; }
    #os-body .grid td.c-cliente small { font-weight: 400; }
    #os-body .grid td.c-tec { order: 4; color: var(--muted); font-size: 12.5px; }
    #os-body .grid td.c-assunto { order: 5; color: var(--muted); font-size: 12.5px; }
    #os-body .grid td.c-tec:not(:empty) + td.c-assunto:not(:empty)::before { content: "·"; margin-right: 6px; color: var(--line-strong); }
    #os-body .grid td.c-doc { order: 6; }
    #os-body .grid td.c-acao { order: 7; margin-left: auto; }
    #os-body .grid td.c-acao .link { font-size: 12.5px; }

    /* Cartão do APR/PT */
    #d-body .grid td.c-os { order: 1; font-weight: 700; color: var(--brand); }
    #d-body .grid td.c-status { order: 2; margin-left: auto; }
    #d-body .grid td.c-cliente { order: 3; flex: 1 1 100%; font-weight: 600; font-size: 14.5px; line-height: 1.3; }
    #d-body .grid td.c-tec, #d-body .grid td.c-data, #d-body .grid td.c-sup { order: 4; color: var(--muted); font-size: 12.5px; }
    #d-body .grid td.c-tec:not(:empty) + td.c-data::before { content: "·"; margin-right: 6px; color: var(--line-strong); }
    #d-body .grid td.c-sup:not(:empty)::before { content: "·"; margin-right: 6px; color: var(--line-strong); }
    #d-body .grid td.c-sup:empty { display: none; }
    #d-body .grid td.c-acao { order: 5; margin-left: auto; }
    #d-body .grid td.c-acao .link { font-size: 12.5px; }

    /* Divisores de grupo viram títulos de seção no celular */
    #d-body .grid tr.linha-grupo { display: block; background: transparent; border: 0; box-shadow: none; padding: 10px 2px 3px; margin: 0; }
    #d-body .grid tr.linha-grupo td {
        background: transparent; border: 0; padding: 0;
        font-size: 11px; color: var(--muted); letter-spacing: .06em;
    }
}
@media (max-width: 420px) {
    .card { padding: 24px 18px; }
    .filters { padding: 10px; }
    .filters input, .filters select { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ── Polimento fino ─────────────────────────────────────── */
::selection { background: rgba(42, 114, 196, .22); }
a:focus-visible, .chip:focus-within, .tab:focus-visible {
    outline: 2px solid var(--brand-3); outline-offset: 2px;
}
#os-body::-webkit-scrollbar, #d-body::-webkit-scrollbar,
#u-body::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { height: 10px; }
#os-body::-webkit-scrollbar-thumb, #d-body::-webkit-scrollbar-thumb,
#u-body::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
    background: #c3cedb; border-radius: 99px; border: 2px solid var(--bg);
}
#os-body::-webkit-scrollbar-track, #d-body::-webkit-scrollbar-track,
#u-body::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }
