:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #d1fae5;
    --bg: #eef2f6;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Segoe UI", Roboto, system-ui, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Topbar ===== */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 0 clamp(14px, 4vw, 28px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: #fff; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar .brand:hover { text-decoration: none; color: #fff; }
.brand-logo { background: #fff; border-radius: 7px; padding: 4px 8px; display: inline-flex; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.brand-logo img { height: 26px; display: block; }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a {
    color: #d1fae5;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.12); text-decoration: none; }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,.18); }
.topbar .user { font-size: 13px; color: #a7f3d0; display: flex; align-items: center; gap: 10px; }
.topbar .user a { color: #fff; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; padding: 4px 8px; }

.container { max-width: 1100px; margin: 28px auto; padding: 0 clamp(12px, 4vw, 20px); }

h1 { font-size: clamp(20px, 4vw, 24px); margin: 0 0 18px; }
h2 { font-size: 17px; margin: 0 0 14px; }

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(16px, 3vw, 22px);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card > h2:first-child { margin-top: 0; }

/* ===== Tables ===== */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f9fafb; }

/* ===== Forms ===== */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; color: #374151; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}
textarea { min-height: 84px; resize: vertical; }

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sec { background: #e2e8f0; color: #1f2937; }
.btn-sec:hover { background: #cbd5e1; color: #1f2937; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.flash { padding: 13px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; border: 1px solid transparent; }
.flash.sucesso { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.flash.erro { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pendente { background: #fef3c7; color: #92400e; }
.badge.resolvida { background: #d1fae5; color: #065f46; }
.badge.atrasada { background: #fee2e2; color: #991b1b; }

/* Categorias SQDCP */
.badge.cat { border: 1px solid transparent; }
.cat-seguranca { background: #fee2e2; color: #991b1b; border-color:#fecaca; }
.cat-qualidade { background: #dbeafe; color: #1e40af; border-color:#bfdbfe; }
.cat-fluxo     { background: #e0e7ff; color: #3730a3; border-color:#c7d2fe; }
.cat-insumos   { background: #fef3c7; color: #92400e; border-color:#fde68a; }
.cat-pessoas   { background: #dcfce7; color: #166534; border-color:#bbf7d0; }
.cat-outros    { background: #e2e8f0; color: #334155; border-color:#cbd5e1; }

/* Prioridade */
.badge.prio { font-weight: 700; }
.prio-alta  { background: #fee2e2; color: #b91c1c; }
.prio-media { background: #fef3c7; color: #92400e; }
.prio-baixa { background: #e2e8f0; color: #475569; }

.tags { display: inline-flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.aging { font-size: 11.5px; color: var(--muted); }

/* ===== Checkboxes grid ===== */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.checks label { display: flex; align-items: center; gap: 9px; font-weight: 400; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.checks label:hover { border-color: var(--primary); background: #f0fdfa; }
.checks input { width: auto; }

.login-wrap { max-width: 400px; margin: clamp(40px, 12vh, 90px) auto; padding: 0 16px; }
.login-wrap .card { text-align: center; }
.login-wrap h1 { font-size: 22px; margin: 4px 0 2px; }
.login-wrap form { text-align: left; }
.login-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 4px auto 14px; }
.muted { color: var(--muted); font-size: 13px; }
.row-actions { white-space: nowrap; }
.inline-form { display: inline; }

/* ===== Stat cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card .num { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-card .lbl { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat-card.warn { border-left-color: #f59e0b; } .stat-card.warn .num { color: #d97706; }
.stat-card.danger { border-left-color: #dc2626; } .stat-card.danger .num { color: #dc2626; }
.stat-card.ok { border-left-color: #059669; } .stat-card.ok .num { color: #059669; }

/* ===== Bar charts (CSS) ===== */
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.bar-row .bar-label { color: #374151; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #f1f5f9; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; transition: width .4s ease; }
.bar-fill.warn { background: #f59e0b; }
.bar-fill.danger { background: #dc2626; }
.bar-fill.ok { background: #059669; }
.bar-val { font-weight: 600; color: #475569; min-width: 28px; text-align: right; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.form-grid > div label:first-child { margin-top: 12px; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .nav-toggle { display: block; order: 3; }
    .topbar .user { order: 4; width: 100%; padding: 8px 0; font-size: 12px; }
    .topbar nav {
        order: 5;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
    }
    .topbar nav.open { max-height: 420px; padding-bottom: 10px; }
    .topbar nav a { padding: 11px 10px; border-radius: 6px; }
}
