:root {
    --bg: #f4f7f8;
    --panel: #ffffff;
    --text: #172126;
    --muted: #6a7981;
    --line: #dbe5e8;
    --green: #35d32f;
    --cyan: #0caeea;
    --dark: #0c1519;
    --danger: #d94b4b;
    --ok: #1c9b62;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top left, rgba(53,211,47,.22), transparent 34%), linear-gradient(135deg, #071014, #14252b);
    padding: 24px;
}
.login-card {
    width: min(440px, 100%);
    background: rgba(255,255,255,.96);
    padding: 34px;
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login-logo-box {
    background: #071014;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 22px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.login-logo { width: 270px; max-width: 100%; display: block; filter: drop-shadow(0 12px 24px rgba(0,0,0,.25)); }
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.login-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    background: #071014;
    color: white;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}
.brand img { width: 208px; max-width: 100%; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar a { border-radius: 8px; padding: 12px 14px; color: rgba(255,255,255,.72); }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(255,255,255,.1); color: white; }
.logout { margin-top: auto; border: 1px solid rgba(255,255,255,.16); }

.app { margin-left: 260px; padding: 28px; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { color: var(--cyan); font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }
h1, h2 { letter-spacing: 0; }
h1 { margin: 4px 0 0; font-size: 30px; }
h2 { margin: 0 0 18px; font-size: 19px; }
.user-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: grid; gap: 2px; min-width: 190px; }
.user-pill span { color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.cards article, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(12,21,25,.05);
}
.cards article { padding: 20px; display: grid; gap: 12px; }
.cards span { color: var(--muted); font-size: 14px; }
.cards strong { font-size: 28px; }
.panel { padding: 20px; }
.narrow-panel { max-width: 520px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.split { display: grid; grid-template-columns: minmax(360px, .85fr) 1fr; gap: 18px; align-items: start; }
.cadastro-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.management-panel { margin-bottom: 18px; }
.company-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.company-list { position: sticky; top: 20px; }
.company-nav { display: grid; gap: 8px; margin-bottom: 18px; max-height: 440px; overflow: auto; }
.company-nav a { display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfdfe; }
.company-nav a.active { border-color: var(--cyan); box-shadow: inset 4px 0 0 var(--cyan); background: #f0fbff; }
.company-nav span, .company-header p, .compact-list span { color: var(--muted); font-size: 13px; }
.company-create { border-top: 1px solid var(--line); padding-top: 16px; }
.company-filter { margin-bottom: 18px; }
.company-filter form { display: grid; grid-template-columns: minmax(240px, 420px) auto; gap: 12px; align-items: end; }
.company-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.company-header h2 { margin: 4px 0 4px; font-size: 24px; }
.company-header p { margin: 0; }
.company-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.company-metrics article { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 8px; }
.company-metrics span { color: var(--muted); font-size: 13px; }
.company-metrics strong { font-size: 26px; }
.compact-list { display: grid; gap: 8px; max-height: 330px; overflow: auto; }
.compact-list div { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--text);
    background: white;
}
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
.check input { width: auto; }
.primary, button {
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--green), var(--cyan));
    color: #051014;
    font-weight: 900;
}
.ghost { background: white; border: 1px solid var(--line); color: var(--text); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.timer { font-size: 34px; font-weight: 900; margin: -6px 0 18px; color: var(--dark); }
.alert { padding: 13px 16px; margin-bottom: 18px; border-radius: 8px; background: #e9f9f1; color: #0d6b41; border: 1px solid #bfe9d2; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: #eef5f6; color: #496069; font-size: 12px; font-weight: 800; }
.badge.danger { background: #fdecec; color: var(--danger); }
.badge.ok { background: #e8f7f0; color: var(--ok); }
.count-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; background: #edf4f5; color: var(--muted); font-size: 12px; font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; }
.activity-list { display: grid; gap: 10px; }
.activity-item { display: flex; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.activity-item div { display: grid; gap: 5px; }
.activity-item span { color: var(--muted); font-size: 13px; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form button { padding: 8px 10px; background: #edf4f5; color: var(--text); }
.button-link { display: inline-flex; align-items: center; border-radius: 8px; padding: 8px 10px; background: #edf4f5; color: var(--text); font-weight: 900; font-size: 14px; }
.compact-action { justify-self: start; margin-top: 4px; }
.edit-panel { border-color: rgba(12,174,234,.45); box-shadow: 0 14px 34px rgba(12,174,234,.08); }
.dossier { margin-bottom: 18px; }
.dossier h3 { margin: 0 0 12px; font-size: 16px; }
.dossier p { color: var(--muted); line-height: 1.55; margin: 0 0 10px; }
.dossier ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.dossier-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.dossier-grid article { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.print-button { white-space: nowrap; }

canvas { width: 100% !important; min-height: 300px; }

@media (max-width: 980px) {
    .sidebar { position: static; width: auto; min-height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
    .sidebar nav { display: flex; }
    .logout { margin-top: 0; margin-left: auto; }
    .app { margin-left: 0; padding: 20px; }
    .cards, .dashboard-grid, .split, .cadastro-grid, .company-shell, .company-metrics, .dossier-grid { grid-template-columns: 1fr; }
    .company-list { position: static; }
    .company-filter form { grid-template-columns: 1fr; }
}

@media print {
    .sidebar, .topbar, .company-filter, .print-button { display: none !important; }
    .app { margin: 0; padding: 0; }
    body { background: white; }
    .panel { box-shadow: none; border-color: #ccd6da; break-inside: avoid; }
    .dossier { border: 0; padding: 0; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .sidebar { padding: 14px; }
    .brand img { width: 150px; }
    h1 { font-size: 25px; }
}
