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

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

:root {
    --bg: #ffffff;
    --bg2: #f5f5f4;
    --bg3: #eeede9;
    --text: #1a1a1a;
    --text2: #6b6b6b;
    --border: rgba(0,0,0,0.1);
    --border2: rgba(0,0,0,0.18);
    --accent: #1A56B0;
    --accent-light: #e6f1fb;
    --accent-text: #0c447c;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body { font-family: 'DM Sans', sans-serif; background: var(--bg2); color: var(--text); font-size: 14px; line-height: 1.5; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--bg2); }
.login-card { background: var(--bg); border: 0.5px solid var(--border2); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.login-logo { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.login-logo span { color: var(--accent); }
.login-sub { font-size: 12px; color: var(--text2); margin-bottom: 1.5rem; }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--bg); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 1.25rem 1.25rem 1rem; font-size: 16px; font-weight: 600; border-bottom: 0.5px solid var(--border); }
.sidebar-logo span { color: var(--accent); }
.sidebar-user { padding: 0.75rem 1.25rem; font-size: 12px; color: var(--text2); border-bottom: 0.5px solid var(--border); }
.sidebar-user strong { display: block; color: var(--text); font-size: 13px; }
.nav { flex: 1; padding: 0.75rem 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 1.25rem; font-size: 13px; color: var(--text2); transition: background 0.15s; border-left: 3px solid transparent; }
.nav a:hover { background: var(--bg2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-light); color: var(--accent-text); border-left-color: var(--accent); font-weight: 500; }
.nav a i { font-size: 16px; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 0.5px solid var(--border); }
.sidebar-footer a { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.sidebar-footer a:hover { color: var(--text); text-decoration: none; }
.main { flex: 1; overflow-x: hidden; }
.topbar { background: var(--bg); border-bottom: 0.5px solid var(--border); padding: 12px 1.5rem; font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.content { padding: 1.5rem; max-width: 1100px; }

/* CARDS */
.card { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card-title { font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 1rem; display: flex; align-items: center; gap: 6px; }

/* METRICS */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; margin-bottom: 1.25rem; }
.metric { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.metric-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 600; }
.metric-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 10px; border: 0.5px solid var(--border2);
    border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
    background: var(--bg); color: var(--text); transition: border 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.full { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: 0.5px solid var(--border2); background: var(--bg); color: var(--text); font-family: inherit; transition: background 0.15s; }
.btn:hover { background: var(--bg2); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; background: var(--accent); }
.btn-danger { color: #a32d2d; border-color: #f09595; }
.btn-danger:hover { background: #fcebeb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ALERTS */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 1rem; }
.alert-success { background: #eaf3de; color: #3b6d11; }
.alert-error { background: #fcebeb; color: #a32d2d; }
.alert-info { background: var(--accent-light); color: var(--accent-text); }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text2); padding: 8px 10px; border-bottom: 0.5px solid var(--border2); white-space: nowrap; background: var(--bg2); }
td { padding: 9px 10px; border-bottom: 0.5px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg2); }
.empty { text-align: center; padding: 2.5rem; color: var(--text2); font-size: 13px; }

/* BADGES */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.badge-blue { background: var(--accent-light); color: var(--accent-text); }
.badge-amber { background: #faeeda; color: #854f0b; }
.badge-green { background: #eaf3de; color: #3b6d11; }
.badge-red { background: #fcebeb; color: #a32d2d; }
.badge-gray { background: var(--bg2); color: var(--text2); }

/* FILTERS */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 1rem; }
.filters .fg { display: flex; flex-direction: column; gap: 3px; }
.filters label { font-size: 11px; color: var(--text2); }
.filters select, .filters input { padding: 6px 8px; font-size: 13px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); background: var(--bg); font-family: inherit; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-title { font-size: 16px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* NOTIFICAÇÕES */
.notif-wrap { position: relative; margin-left: auto; }
.notif-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: none; border: none; cursor: pointer; color: var(--text2); font-size: 20px; border-radius: var(--radius-sm); transition: background 0.15s; }
.notif-btn:hover { background: var(--bg2); color: var(--text); }
.notif-badge { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px; background: var(--accent); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; border: 2px solid var(--bg); }
.notif-badge-red { background: #c53030; }
.notif-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 300px; background: var(--bg); border: 0.5px solid var(--border2); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 300; overflow: hidden; }
.notif-dropdown.open { display: block; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-size: 12px; font-weight: 600; border-bottom: 0.5px solid var(--border); background: var(--bg2); }
.notif-ver-todas { font-size: 11px; font-weight: 400; color: var(--accent); }
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 0.5px solid var(--border); text-decoration: none; color: var(--text); transition: background 0.15s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg2); text-decoration: none; }
.notif-item-titulo { font-size: 12px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-meta { font-size: 11px; color: var(--text2); }
.notif-empty { padding: 24px 14px; text-align: center; font-size: 12px; color: var(--text2); }
.nav-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; background: var(--accent); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* REGISTRO MULTI-LINHA */
.reg-linhas-header { display: grid; grid-template-columns: 180px 130px 130px 1fr 40px; gap: 8px; padding: 0 4px 6px; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 0.5px solid var(--border); margin-bottom: 6px; }
.reg-linha { display: grid; grid-template-columns: 180px 130px 130px 1fr 40px; gap: 8px; align-items: center; padding: 6px 4px; border-radius: var(--radius-sm); }
.reg-linha:hover { background: var(--bg2); }
.reg-linha-field { display: flex; flex-direction: column; gap: 3px; }
.reg-linha-label { display: none; font-size: 11px; color: var(--text2); }
.reg-linha-field input, .reg-linha-field select { width: 100%; padding: 7px 9px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--bg); color: var(--text); }
.reg-linha-field input:focus, .reg-linha-field select:focus { outline: none; border-color: var(--accent); }
.reg-linha-remove { display: flex; justify-content: center; }

@media (max-width: 700px) {
  .reg-linhas-header { display: none; }
  .reg-linha { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
  .reg-linha-label { display: block; }
  .reg-linha-obs { grid-column: 1 / -1; }
  .reg-linha-remove { grid-column: 1 / -1; justify-content: flex-end; }
}

/* TAREFAS */
.tarefas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.tarefa-card { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 1.1rem; display: flex; flex-direction: column; gap: 8px; }
.tarefa-card:hover { border-color: var(--border2); }
.tarefa-cancelada { opacity: 0.55; }
.tarefa-card-header { display: flex; gap: 10px; align-items: flex-start; }
.tarefa-titulo { font-size: 14px; font-weight: 500; line-height: 1.4; }
.tarefa-desc { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tarefa-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--text2); }
.tarefa-meta span { display: flex; align-items: center; gap: 4px; }
.tarefa-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.progress-bar { height: 5px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.progress-done { background: #3b6d11; }
.tarefa-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.tarefa-item-done { background: var(--bg2); opacity: 0.75; }
.tarefa-item-check { flex-shrink: 0; }
.tarefa-dash-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; transition: background 0.15s; }
.tarefa-dash-item:hover { background: var(--bg2); text-decoration: none; }

/* COLETA */
.coleta-aberta-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.coleta-aberta-item:hover { border-color: var(--border2); background: var(--bg2); }
.tr-editing { background: var(--accent-light); }
.prod-check-label { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.prod-check-label:hover { background: var(--bg2); }
.prod-check-label input[type="checkbox"] { width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; accent-color: var(--accent); }

/* AUTOCOMPLETE */
.autocomplete-wrap { position: relative; }
.autocomplete-input { width: 100%; padding: 8px 10px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; background: var(--bg); color: var(--text); transition: border 0.15s; }
.autocomplete-input:focus { outline: none; border-color: var(--accent); }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); border: 0.5px solid var(--border2); border-radius: var(--radius-sm); box-shadow: 0 4px 16px rgba(0,0,0,0.1); z-index: 100; list-style: none; margin: 2px 0 0; padding: 4px 0; max-height: 240px; overflow-y: auto; display: none; }
.ac-item { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text); }
.ac-item:hover, .ac-item.ac-active { background: var(--accent-light); color: var(--accent-text); }
.ac-item mark { background: none; color: var(--accent); font-weight: 600; }

/* CHARTS */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1rem; }
.chart-card { min-height: 220px; }
.chart-card-full { margin-bottom: 1rem; }

/* PAGINATION */
.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 1rem; margin-top: 0.5rem; border-top: 0.5px solid var(--border); flex-wrap: wrap; gap: 8px; }
.pag-info { font-size: 12px; color: var(--text2); }
.pag-links { display: flex; align-items: center; gap: 4px; }
.pag-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: var(--radius-sm); font-size: 12px; border: 0.5px solid var(--border2); background: var(--bg); color: var(--text); cursor: pointer; transition: background 0.15s; text-decoration: none; }
.pag-btn:hover { background: var(--bg2); text-decoration: none; }
.pag-current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.pag-current:hover { background: var(--accent); opacity: 0.9; }
.pag-disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.pag-ellipsis { font-size: 12px; color: var(--text2); padding: 0 2px; }

/* MOBILE NAV */
.mob-hamburger { display: none; }
.mob-nav { display: none; }
.mob-overlay { display: none; }
.mob-drawer { display: none; }

@media (max-width: 700px) {
    /* Layout */
    .sidebar { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .charts-row { grid-template-columns: 1fr; }
    .content { padding: 1rem; padding-bottom: 5rem; }
    .topbar { display: flex; align-items: center; gap: 10px; padding: 0 1rem; height: 52px; position: sticky; top: 0; z-index: 10; background: var(--bg); }
    .notif-dropdown { right: -8px; width: 280px; }
    .topbar-title { font-size: 15px; font-weight: 500; }

    /* Hamburguer */
    .mob-hamburger { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: none; border: none; cursor: pointer; color: var(--text); font-size: 22px; flex-shrink: 0; border-radius: var(--radius-sm); }
    .mob-hamburger:hover { background: var(--bg2); }

    /* Overlay */
    .mob-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
    .mob-overlay.open { opacity: 1; pointer-events: all; }

    /* Drawer lateral */
    .mob-drawer { display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; width: 80%; max-width: 300px; background: var(--bg); z-index: 201; transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
    .mob-drawer.open { transform: translateX(0); }
    .mob-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem; border-bottom: 0.5px solid var(--border); }
    .mob-close { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--bg2); border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 18px; color: var(--text); }
    .mob-drawer-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
    .mob-drawer-nav a { display: flex; align-items: center; gap: 12px; padding: 14px 1.25rem; font-size: 14px; color: var(--text2); border-left: 3px solid transparent; }
    .mob-drawer-nav a:hover { background: var(--bg2); color: var(--text); text-decoration: none; }
    .mob-drawer-nav a.active { background: var(--accent-light); color: var(--accent-text); border-left-color: var(--accent); font-weight: 500; }
    .mob-drawer-nav a i { font-size: 20px; }
    .mob-drawer-footer { padding: 1rem 1.25rem; border-top: 0.5px solid var(--border); }
    .mob-drawer-footer a { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text2); padding: 10px 0; }

    /* Bottom nav */
    .mob-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg); border-top: 0.5px solid var(--border); z-index: 100; padding-bottom: env(safe-area-inset-bottom); }
    .mob-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 4px; font-size: 10px; color: var(--text2); border: none; background: none; cursor: pointer; font-family: inherit; text-decoration: none; min-height: 56px; }
    .mob-nav-item i { font-size: 22px; }
    .mob-nav-item.active { color: var(--accent); }
    .mob-nav-item.active i { color: var(--accent); }
    .mob-nav-item:hover { background: var(--bg2); text-decoration: none; }

    /* Touch targets */
    .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; }
    select, input[type="text"], input[type="date"], input[type="number"], input[type="password"], input[type="email"], textarea { min-height: 44px; font-size: 16px !important; } /* font-size 16px evita zoom no iOS */
    .autocomplete-input { min-height: 44px; font-size: 16px !important; }
    .ac-item { padding: 14px 16px; font-size: 15px; }
    .filters select, .filters input { min-height: 40px; font-size: 14px; }

    /* Tabelas */
    th { font-size: 10px; padding: 6px 8px; }
    td { font-size: 12px; padding: 10px 8px; }

    /* Cards */
    .card { padding: 1rem; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .metric-value { font-size: 20px; }

    /* Paginação */
    .pag-info { width: 100%; text-align: center; }
    .pag-links { justify-content: center; width: 100%; }
    .pag-btn { min-width: 40px; height: 40px; font-size: 14px; }
}
