/* ============================================================
   SISTEMA DFD — PREFEITURA DE BOQUIM
   Design: Institucional Refinado / Azul Governo
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --azul:        #0d3b6e;
    --azul-mid:    #1a5276;
    --azul-light:  #2471a3;
    --azul-pale:   #d6eaf8;
    --verde:       #1e8449;
    --verde-pale:  #d5f5e3;
    --amarelo:     #d4ac0d;
    --amarelo-pale:#fef9e7;
    --vermelho:    #c0392b;
    --verm-pale:   #fadbd8;
    --cinza-1:     #f4f6f8;
    --cinza-2:     #e8ecf0;
    --cinza-3:     #bdc3c7;
    --cinza-4:     #7f8c8d;
    --cinza-5:     #2c3e50;
    --branco:      #ffffff;
    --sombra:      0 2px 12px rgba(13,59,110,.10);
    --sombra-md:   0 4px 24px rgba(13,59,110,.14);
    --radius:      8px;
    --font-title:  'Source Serif 4', Georgia, serif;
    --font-body:   'DM Sans', sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--cinza-1);
    color: var(--cinza-5);
    min-height: 100vh;
}

/* ── LAYOUT ─────────────────────────────────────────────── */

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

/* ── SIDEBAR ─────────────────────────────────────────────── */

.sidebar {
    width: 255px;
    background: var(--azul);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand .brasao {
    width: 44px;
    height: 44px;
    background: var(--branco);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 10px;
}

.sidebar-brand h1 {
    font-family: var(--font-title);
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.sidebar-brand p {
    font-size: .72rem;
    color: rgba(255,255,255,.55);
    margin-top: 2px;
}

.sidebar-user {
    padding: 14px 20px;
    background: rgba(255,255,255,.06);
    font-size: .8rem;
    color: rgba(255,255,255,.75);
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-user strong {
    display: block;
    color: #fff;
    font-weight: 600;
    font-size: .85rem;
}

.sidebar-user span {
    font-size: .72rem;
    opacity: .7;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 0;
}

.nav-section {
    padding: 10px 20px 4px;
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: rgba(255,255,255,.4);
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 400;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--amarelo);
}

.nav-link .icon {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    opacity: .85;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: .82rem;
    transition: color .15s;
}

.sidebar-footer a:hover { color: #fff; }

/* ── MAIN CONTENT ─────────────────────────────────────────── */

.main {
    margin-left: 255px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--branco);
    border-bottom: 1px solid var(--cinza-2);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.topbar-title {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--azul);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: .82rem;
    color: var(--cinza-4);
}

.content {
    padding: 28px 32px;
    flex: 1;
}

/* ── CARDS ───────────────────────────────────────────────── */

.card {
    background: var(--branco);
    border-radius: var(--radius);
    box-shadow: var(--sombra);
    border: 1px solid var(--cinza-2);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--cinza-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 {
    font-family: var(--font-title);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--azul);
}

.card-body {
    padding: 24px;
}

/* ── STAT CARDS ──────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 20px 22px;
    border: 1px solid var(--cinza-2);
    box-shadow: var(--sombra);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: var(--sombra-md); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.azul  { background: var(--azul-pale);   }
.stat-icon.verde { background: var(--verde-pale);   }
.stat-icon.ouro  { background: var(--amarelo-pale); }
.stat-icon.cinza { background: var(--cinza-2);      }

.stat-label {
    font-size: .75rem;
    color: var(--cinza-4);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--azul);
    line-height: 1;
    font-family: var(--font-title);
}

/* ── BOTÕES ──────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: filter .15s, box-shadow .15s, transform .1s;
    white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--azul-light); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }

.btn-success   { background: var(--verde); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

.btn-warning   { background: var(--amarelo); color: #fff; }
.btn-danger    { background: var(--vermelho); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-outline   {
    background: transparent;
    border: 1.5px solid var(--cinza-3);
    color: var(--cinza-5);
}
.btn-outline:hover { border-color: var(--azul-light); color: var(--azul); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ── TABELAS ─────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table thead th {
    background: var(--cinza-1);
    color: var(--cinza-4);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    padding: 11px 16px;
    border-bottom: 2px solid var(--cinza-2);
    text-align: left;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--cinza-2);
    transition: background .12s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--cinza-1); }

.data-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

/* ── FORMULÁRIOS ─────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }

label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--cinza-5);
    text-transform: uppercase;
    letter-spacing: .05em;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
select,
textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--cinza-2);
    border-radius: 6px;
    font-size: .9rem;
    font-family: var(--font-body);
    color: var(--cinza-5);
    background: var(--branco);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--azul-light);
    box-shadow: 0 0 0 3px rgba(36,113,163,.12);
}

textarea { resize: vertical; min-height: 90px; }

.form-hint {
    font-size: .75rem;
    color: var(--cinza-4);
    margin-top: 2px;
}

/* ── BADGES / TAGS ───────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.badge-rascunho  { background: var(--cinza-2);      color: var(--cinza-4); }
.badge-finalizado{ background: var(--verde-pale);   color: var(--verde);   }
.badge-cancelado { background: var(--verm-pale);    color: var(--vermelho);}
.badge-baixo     { background: var(--verde-pale);   color: var(--verde);   }
.badge-medio     { background: var(--amarelo-pale); color: #7d6608;        }
.badge-alto      { background: var(--verm-pale);    color: var(--vermelho);}

/* ── ALERTS / FLASH ──────────────────────────────────────── */

.alert {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: var(--verde-pale); color: var(--verde); border-left: 4px solid var(--verde); }
.alert-error   { background: var(--verm-pale);  color: var(--vermelho); border-left: 4px solid var(--vermelho); }
.alert-info    { background: var(--azul-pale);  color: var(--azul);    border-left: 4px solid var(--azul);    }
.alert-warning { background: var(--amarelo-pale); color: #7d6608; border-left: 4px solid var(--amarelo); }

/* ── PAGE HEADER ─────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
}

.page-header h1 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: var(--azul);
    font-weight: 700;
}

.page-header p {
    font-size: .85rem;
    color: var(--cinza-4);
    margin-top: 3px;
}

/* ── DFD PRINT ───────────────────────────────────────────── */

.dfd-print-wrap {
    background: var(--branco);
    max-width: 820px;
    margin: 0 auto;
    padding: 36px;
    font-family: var(--font-body);
    font-size: .88rem;
    color: #000;
}

.dfd-cabecalho {
    display: flex;
    align-items: center;
    gap: 18px;
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.dfd-cabecalho .brasao-print {
    width: 60px;
    height: 60px;
    border: 2px solid #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.dfd-title-block { flex: 1; text-align: center; }

.dfd-title-block h2 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dfd-title-block h3 {
    font-size: .85rem;
    font-weight: 400;
    margin-top: 3px;
}

.dfd-numero { font-size: .82rem; text-align: right; white-space: nowrap; }

.dfd-secao {
    border: 1.5px solid #333;
    margin-bottom: -1px;
}

.dfd-secao-titulo {
    background: #d9d9d9;
    font-weight: 700;
    font-size: .82rem;
    padding: 5px 10px;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid #333;
}

.dfd-secao-corpo {
    padding: 8px 10px;
}

.dfd-row {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #ccc;
}

.dfd-row:last-child { border-bottom: none; }

.dfd-campo {
    flex: 1;
    padding: 5px 10px;
    font-size: .82rem;
    border-right: 1px solid #ccc;
}

.dfd-campo:last-child { border-right: none; }

.dfd-campo label {
    display: block;
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #444;
    margin-bottom: 2px;
}

.dfd-campo p { font-size: .85rem; }

.dfd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.dfd-table th {
    background: #d9d9d9;
    border: 1px solid #333;
    padding: 5px 8px;
    text-align: center;
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
}

.dfd-table td {
    border: 1px solid #aaa;
    padding: 5px 8px;
    vertical-align: middle;
}

.dfd-table .total-row td {
    background: #f0f0f0;
    font-weight: 700;
    border-color: #333;
}

.dfd-prioridade-grid {
    display: flex;
    gap: 16px;
    padding: 6px 10px;
    font-size: .82rem;
}

.dfd-check { display: flex; align-items: center; gap: 6px; }

.dfd-box {
    width: 14px;
    height: 14px;
    border: 2px solid #000;
    display: inline-block;
    vertical-align: middle;
}

.dfd-box.checked::after {
    content: '✖';
    display: block;
    font-size: 11px;
    line-height: 14px;
    text-align: center;
    font-weight: 900;
}

.dfd-assinaturas {
    display: flex;
    justify-content: space-around;
    margin-top: 40px;
    gap: 30px;
    text-align: center;
    font-size: .82rem;
}

.dfd-assinatura-bloco {
    flex: 1;
}

.dfd-assinatura-linha {
    border-top: 1.5px solid #000;
    margin-top: 40px;
    padding-top: 6px;
}

/* ── ITENS TABLE (form DFD) ──────────────────────────────── */

.itens-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.itens-table th {
    background: var(--cinza-1);
    padding: 9px 12px;
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    color: var(--cinza-4);
    letter-spacing: .07em;
    border-bottom: 2px solid var(--cinza-2);
}
.itens-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--cinza-2);
    vertical-align: middle;
}
.itens-table input, .itens-table select {
    padding: 6px 10px;
    font-size: .85rem;
}
.valor-total-linha {
    font-weight: 700;
    color: var(--azul);
}
.total-row-form {
    background: var(--azul-pale);
    font-weight: 700;
}

/* ── LOGIN ───────────────────────────────────────────────── */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--azul) 0%, var(--azul-light) 100%);
    padding: 20px;
}

.login-card {
    background: var(--branco);
    border-radius: 12px;
    padding: 44px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .brasao {
    width: 64px;
    height: 64px;
    background: var(--azul);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin: 0 auto 12px;
}

.login-logo h1 {
    font-family: var(--font-title);
    font-size: 1.3rem;
    color: var(--azul);
}

.login-logo p {
    font-size: .8rem;
    color: var(--cinza-4);
    margin-top: 3px;
}

/* ── RESPONSIVO ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main {
        margin-left: 0;
    }
    .content {
        padding: 18px 16px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group.span-2, .form-group.span-3 {
        grid-column: span 1;
    }
    .page-header {
        flex-direction: column;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── PRINT ───────────────────────────────────────────────── */

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: none !important; }
}

/* ── UTILITÁRIOS ─────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--cinza-4); font-size: .82rem; }
.fw-bold     { font-weight: 700; }
.mt-4        { margin-top: 16px; }
.mt-6        { margin-top: 24px; }
.mb-4        { margin-bottom: 16px; }
.gap-2       { gap: 8px; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.divider     { border: none; border-top: 1px solid var(--cinza-2); margin: 20px 0; }
