:root {
    --brand: #0d4f8b;
    --brand-dark: #093a66;
    --bg: #f2f4f7;
    --card: #ffffff;
    --text: #1b2733;
    --muted: #6b7785;
    --warn: #c47f00;
    --ok: #1d8a4e;
    --radius: 14px;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Header fixo ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--brand);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.app-header__inner {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 8px;
}
.app-header__title {
    flex: 1;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-header__btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    font-size: 1.3rem;
    border-radius: 50%;
    /* reset de estilo nativo do <button> (senão vira um círculo cinza com borda) */
    background: transparent;
    border: none;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.app-header__btn:active { background: rgba(255,255,255,.18); }
.app-header__btn:focus { outline: none; }
.app-header__btn:focus-visible { outline: 2px solid rgba(255,255,255,.6); }

/* ---------- Conteúdo ---------- */
.app-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Login ---------- */
.login-wrap {
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .mark {
    width: 76px; height: 76px;
    border-radius: 20px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}
.login-logo h1 { font-size: 1.25rem; margin-top: 14px; }
.login-logo p { color: var(--muted); margin: 0; }

/* ---------- Form controls (alvos grandes p/ toque) ---------- */
.form-control, .form-select {
    min-height: 52px;
    border-radius: 12px;
    font-size: 1rem;
}
textarea.form-control { min-height: 90px; }
.btn {
    border-radius: 12px;
    font-weight: 600;
}
.btn-lg-touch {
    min-height: 52px;
    font-size: 1.05rem;
}
.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-brand:hover, .btn-brand:active { background: var(--brand-dark); border-color: var(--brand-dark); color:#fff; }

/* ---------- Filtro ---------- */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.filter-bar .form-control, .filter-bar .form-select { min-height: 46px; }

/* ---------- Cards de OS ---------- */
.os-card {
    display: block;
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(16,24,40,.08);
    border: 1px solid #eef1f4;
}
.os-card:active { background: #fafbfc; }
.os-card__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.os-card__id { font-size: .78rem; color: var(--muted); font-weight: 600; }
.os-card__title { font-weight: 600; margin: 2px 0 6px; line-height: 1.25; }
.os-card__msg {
    color: var(--muted);
    font-size: .88rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.os-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 10px;
    font-size: .78rem;
    color: var(--muted);
}
.badge-pend {
    background: #fff4e0;
    color: var(--warn);
    border: 1px solid #f3dcae;
    font-size: .72rem;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- Detalhe / trâmites ---------- */
.detail-head {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(16,24,40,.08);
}
.detail-head h2 { font-size: 1.05rem; margin: 0 0 6px; }
.msg {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(16,24,40,.06);
}
.msg__head {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    margin-bottom: 4px;
    gap: 8px;
}
.msg__autor { font-weight: 600; }
.msg__cargo { color: var(--muted); }
.msg__date { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.msg__body { font-size: .92rem; line-height: 1.35; word-wrap: break-word; }
.msg--auth { border-left: 4px solid var(--ok); }

.anexos { margin: 6px 0 16px; }
.anexo-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef3f9;
    color: var(--brand);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: .82rem;
    text-decoration: none;
    margin: 0 6px 6px 0;
}

.section-label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 700;
    margin: 6px 2px 8px;
}

/* ---------- Barra de ação fixa (autorizar) ---------- */
.action-bar {
    position: sticky;
    bottom: 0;
    background: var(--card);
    margin: 16px -14px calc(-24px - env(safe-area-inset-bottom));
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #e7ebef;
    box-shadow: 0 -2px 8px rgba(16,24,40,.06);
}

/* ---------- Menu lateral (offcanvas) ---------- */
.offcanvas {
    max-width: 84vw;
    width: 320px;
}
.app-menu__header {
    background: var(--brand);
    color: #fff;
    padding-top: calc(.75rem + env(safe-area-inset-top));
}
.app-menu__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .25);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 auto;
}
.app-menu__item {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    border: none;
}
.app-menu__item:active {
    background: #eef3f9;
}
.app-menu__icon {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}

/* ---------- Indicador de carregamento global ---------- */
.app-loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 79, 139, .35);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}
.app-loading[hidden] { display: none; }
.app-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: .3em;
}

/* ---------- Combo com busca (searchable select) ---------- */
.ss-wrap { position: relative; }
.ss-display {
    text-align: left;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: #fff;
}
.ss-display.ss-empty-val { color: #6c757d; }
.ss-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 1050;
    background: #fff;
    border: 1px solid #cdd6e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16,24,40,.18);
    padding: 8px;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
}
.ss-search { margin-bottom: 8px; }
.ss-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.ss-item {
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.25;
}
.ss-item:active, .ss-item:hover { background: #eef3f9; }
.ss-item--sel { background: #e8f0fb; font-weight: 600; }
.ss-noresult { padding: 14px; text-align: center; color: var(--muted); }

/* ---------- Estados ---------- */
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 48px 16px;
}
.alert { border-radius: 12px; }
