/* ============================================
   SISTEMA DE GESTAO DE BATERIAS - Design System
   ============================================ */

:root {
    /* Primary palette */
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;

    /* Neutral palette */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Dimensions */
    --nav-height: 60px;

    /* Status colors */
    --verde: #10b981;
    --verde-dark: #059669;
    --verde-bg: #d1fae5;
    --verde-ring: rgba(16,185,129,.25);

    --laranja: #f59e0b;
    --laranja-dark: #d97706;
    --laranja-bg: #fef3c7;
    --laranja-ring: rgba(245,158,11,.25);

    --vermelho: #ef4444;
    --vermelho-dark: #dc2626;
    --vermelho-bg: #fee2e2;
    --vermelho-ring: rgba(239,68,68,.25);

    --cinza: #6b7280;
    --cinza-dark: #4b5563;
    --cinza-bg: #e5e7eb;
    --cinza-ring: rgba(107,114,128,.25);
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 13px;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   NAVIGATION
   ============================================ */

nav {
    background: #0f172a;
    padding: 0 32px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    gap: 4px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #1e293b;
}

nav a {
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all .2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: .02em;
}

nav a:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,.06);
}

nav a.active {
    color: #fff;
    background: rgba(79,70,229,.2);
}

nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--primary-light);
    border-radius: 1px;
}

nav .brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    margin-right: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -.02em;
}

nav .brand span {
    color: var(--primary-light);
}

/* ============================================
   LAYOUT
   ============================================ */

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -.03em;
}

h1 .icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

h1 .icon.dash { background: var(--primary-bg); color: var(--primary); }
h1 .icon.geren { background: #ecfdf5; color: var(--verde); }
h1 .icon.busca { background: #fef3c7; color: var(--laranja); }
h1 .icon.import { background: #ede9fe; color: #7c3aed; }

h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 16px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

h2 .badge {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    color: var(--primary);
}

/* ============================================
   MESSAGES
   ============================================ */

.msg {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown .3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg.ok {
    background: var(--verde-bg);
    color: #065f46;
    border-left: 4px solid var(--verde);
}

.msg.erro {
    background: var(--vermelho-bg);
    color: #991b1b;
    border-left: 4px solid var(--vermelho);
}

/* ============================================
   SUMMARY CARDS (Dashboard)
   ============================================ */

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all .2s ease;
    position: relative;
    overflow: hidden;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card .sc-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

.summary-card .sc-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.1;
}

.summary-card .sc-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

.summary-card .sc-bar {
    height: 2px;
    border-radius: 1px;
    margin-top: 8px;
    width: 100%;
}

.summary-card.verde-card { border-top: 3px solid var(--verde); }
.summary-card.verde-card .sc-value { color: var(--verde-dark); }
.summary-card.verde-card .sc-bar { background: var(--verde); }

.summary-card.laranja-card { border-top: 3px solid var(--laranja); }
.summary-card.laranja-card .sc-value { color: var(--laranja-dark); }
.summary-card.laranja-card .sc-bar { background: var(--laranja); }

.summary-card.vermelho-card { border-top: 3px solid var(--vermelho); }
.summary-card.vermelho-card .sc-value { color: var(--vermelho-dark); }
.summary-card.vermelho-card .sc-bar { background: var(--vermelho); }

.summary-card.cinza-card { border-top: 3px solid var(--cinza); }
.summary-card.cinza-card .sc-value { color: var(--cinza-dark); }
.summary-card.cinza-card .sc-bar { background: var(--cinza); }

.summary-card.total-card { border-top: 3px solid var(--primary); }
.summary-card.total-card .sc-value { color: var(--primary); }
.summary-card.total-card .sc-bar { background: var(--primary); }

.summary-card.active {
    transform: translateY(-2px);
    box-shadow: 0 0 0 2px rgba(79,70,229,.3), var(--shadow-md);
}

/* ============================================
   LEGEND / FILTER TAGS
   ============================================ */

.legenda {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all .2s ease;
    border: 2px solid transparent;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tag:active {
    transform: translateY(0);
}

.tag.verde {
    background: var(--verde);
    box-shadow: 0 2px 8px var(--verde-ring);
}
.tag.laranja {
    background: var(--laranja);
    box-shadow: 0 2px 8px var(--laranja-ring);
}
.tag.vermelho {
    background: var(--vermelho);
    box-shadow: 0 2px 8px var(--vermelho-ring);
}
.tag.cinza {
    background: var(--cinza);
    box-shadow: 0 2px 8px var(--cinza-ring);
}

.tag.total {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.tag.total:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

.tag.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(0,0,0,.15), var(--shadow-md);
    transform: translateY(-2px);
}

.tag-static {
    cursor: default;
    pointer-events: none;
    display: inline-flex;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-full);
    color: #fff;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

.tag-static.verde { background: var(--verde); }
.tag-static.laranja { background: var(--laranja); }
.tag-static.vermelho { background: var(--vermelho); }
.tag-static.cinza { background: var(--cinza); }

.tag .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,.2);
    font-size: 10px;
    font-weight: 700;
}

.tag.total .count {
    background: var(--primary-bg);
    color: var(--primary);
}

/* ============================================
   GRID (Dashboard)
   ============================================ */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 5px;
}

.grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.celula {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    text-align: center;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: #fff;
    transition: all .15s ease;
    word-break: break-word;
    line-height: 1.2;
    position: relative;
    overflow: hidden;
    min-height: 46px;
}

.celula .celula-status {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .7;
    margin-top: 2px;
    font-weight: 500;
}

.celula::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,.08) 0%, transparent 50%);
    pointer-events: none;
}

.celula:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,.25);
}



.celula.hidden {
    display: none;
}

.celula.fade-in {
    animation: cellFadeIn .35s ease forwards;
}

@keyframes cellFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.boa-autonomia {
    background: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
}

.media-autonomia {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #fbbf24 100%);
}

.baixa-autonomia {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 50%, #f87171 100%);
}

.sem-bateria {
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 50%, #9ca3af 100%);
}

/* ============================================
   CARD
   ============================================ */

.card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: box-shadow .2s;
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card + .card {
    margin-top: 12px;
}

/* ============================================
   FORM
   ============================================ */

.form-section {
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.form-section-header {
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 14px 16px;
}

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

.form-group label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    transition: all .2s;
    background: #fff;
    color: var(--text);
}

.form-group input:hover, .form-group select:hover {
    border-color: #cbd5e1;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0 16px 14px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    transition: all .2s;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79,70,229,.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--cinza);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--cinza-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(107,114,128,.3);
}

.btn-danger {
    background: var(--vermelho);
    color: #fff;
}

.btn-danger:hover {
    background: var(--vermelho-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239,68,68,.3);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

/* ============================================
   TABLE
   ============================================ */

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 12px;
}

table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .05em;
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

table tbody tr {
    transition: background .15s;
}

table tbody tr:last-child td {
    border-bottom: none;
}

table tbody tr:nth-child(even) {
    background: #fafbfc;
}

table tbody tr:hover {
    background: var(--primary-bg);
}

table .actions {
    display: flex;
    gap: 4px;
}

table .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: all .15s;
    text-decoration: none;
    background: transparent;
}

table .btn-icon.edit {
    color: var(--primary);
}
table .btn-icon.edit:hover {
    background: var(--primary-bg);
}

table .btn-icon.delete {
    color: var(--vermelho);
}
table .btn-icon.delete:hover {
    background: var(--vermelho-bg);
}

/* ============================================
   SEARCH
   ============================================ */

.search-box {
    margin-bottom: 14px;
}

.search-box form {
    display: flex;
    gap: 8px;
    max-width: 500px;
}

.search-box input {
    flex: 1;
    padding: 8px 14px;
    font-size: 13px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all .2s;
    background: var(--surface);
    color: var(--text);
}

.search-box input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: .4;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   FILE INPUT
   ============================================ */

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type=file] {
    width: 100%;
    padding: 24px 16px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.file-input-wrapper input[type=file]:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.file-input-wrapper input[type=file]::file-selector-button {
    display: none;
}

/* ============================================
   CHECKBOX CUSTOM
   ============================================ */

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}

.checkbox-group:hover {
    background: var(--primary-bg);
}

.checkbox-group input[type=checkbox] {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--border);
    cursor: pointer;
    accent-color: var(--primary);
}

/* ============================================
   STATUS INDICATOR DOT
   ============================================ */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.verde { background: var(--verde); }
.status-dot.laranja { background: var(--laranja); }
.status-dot.vermelho { background: var(--vermelho); }
.status-dot.cinza { background: var(--cinza); }

/* ============================================
   NO DATA BADGE
   ============================================ */

.no-data {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

/* ============================================
   CHARTS (Relatório)
   ============================================ */

.chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.chart-row + .chart-row {
    border-top: 1px solid var(--border-light);
}

.chart-label {
    min-width: 140px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-value {
    min-width: 80px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

.chart-bar-bg {
    flex: 1;
    height: 22px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.chart-bar {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width .6s ease;
    min-width: 0;
}

.chart-bar.verde { background: linear-gradient(90deg, var(--verde-dark), var(--verde)); }
.chart-bar.laranja { background: linear-gradient(90deg, var(--laranja-dark), var(--laranja)); }
.chart-bar.vermelho { background: linear-gradient(90deg, var(--vermelho-dark), var(--vermelho)); }
.chart-bar.cinza { background: linear-gradient(90deg, var(--cinza-dark), var(--cinza)); }

.mini-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
    max-width: 200px;
}

.mini-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width .4s ease;
}

.mini-bar-fill.primary { background: var(--primary); }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .container { padding: 12px 16px; }
    .summary { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

@media (max-width: 768px) {
    nav {
        padding: 0 12px;
        gap: 2px;
        overflow-x: auto;
    }
    nav .brand { margin-right: 8px; font-size: 13px; }
    nav a { font-size: 11px; padding: 4px 8px; white-space: nowrap; }
    nav a.active::after { width: 30%; }

    .container { padding: 10px 12px; }

    h1 { font-size: 16px; }
    .page-header { margin-bottom: 10px; }

    .summary { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .summary-card { padding: 10px 12px; }
    .summary-card .sc-value { font-size: 18px; }

    .grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 4px; }
    .celula { padding: 6px 4px; font-size: 10px; min-height: 38px; }

    .form-grid { grid-template-columns: 1fr; padding: 10px 12px; }
    .form-actions { padding: 0 12px 10px; }

    .legenda { gap: 4px; }
    .tag { font-size: 10px; padding: 3px 8px; }

    table { font-size: 11px; }
    table th, table td { padding: 5px 8px; }
    table th { font-size: 9px; }

    .card { padding: 12px 14px; }

    .file-input-wrapper input[type=file] { padding: 16px 12px; }

    .chart-row { flex-wrap: wrap; gap: 6px; }
    .chart-label { min-width: 120px; }
    .chart-value { min-width: 60px; }
}

@media (max-width: 480px) {
    .summary { grid-template-columns: 1fr 1fr; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .chart-label { min-width: 0; width: 100%; }
    .chart-value { min-width: 50px; }
}
