:root {
  --navy: #1B2430;
  --navy-2: #232E3D;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --line: #E4E7EC;
  --text: #1B2430;
  --muted: #5B6472;
  --amber: #D88A2A;
  --amber-dark: #B8721E;
  --green: #2E7D5B;
  --green-bg: #E7F4ED;
  --red: #C44545;
  --red-bg: #FBEAEA;
  --radius: 10px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, #2B384A 100%);
}
.login-card {
  background: var(--card); padding: 36px 32px; border-radius: 14px; width: 320px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-mark { font-size: 28px; color: var(--amber); }
.login-card h1 { margin: 4px 0 2px; }
.login-card p { margin-top: 0; margin-bottom: 20px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 6px; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }
.sidebar {
  width: 220px; background: var(--navy); color: #C9CFD8; display: flex; flex-direction: column;
  padding: 20px 14px; flex-shrink: 0;
}
.brand { color: #fff; font-weight: 700; font-size: 17px; margin: 4px 8px 22px; display: flex; gap: 8px; align-items: center; }
.brand-mark { color: var(--amber); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  background: none; border: none; color: #C9CFD8; text-align: left; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--amber); color: #1B2430; }
.nav-item.logout { color: #8B95A3; }

.content { flex: 1; padding: 28px 36px; max-width: 1100px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; flex-wrap: wrap; gap: 10px; }
.view-header .row { margin-bottom: 0; }

/* =====================================================
   MOBILE (<= 860px): sidebar passa a ser um drawer (menu
   deslizante) acionado pelo botão hamburguer no topo.
   ===================================================== */
@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 40;
    background: var(--navy); color: #fff; padding: 12px 14px;
    height: 52px; flex-shrink: 0;
  }
  .mobile-brand { font-weight: 700; font-size: 15px; display: flex; gap: 7px; align-items: center; }
  .hamburger {
    background: none; border: none; padding: 6px; margin: -6px; cursor: pointer;
    display: flex; flex-direction: column; gap: 4px; justify-content: center;
    width: 32px; height: 32px;
  }
  .hamburger span { display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; }

  .app { flex-direction: column; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 250px; max-width: 80vw;
    z-index: 60; transform: translateX(-100%); transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { display: none; } /* já aparece na topbar mobile */

  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(15,20,27,0.5); z-index: 50; opacity: 0;
    visibility: hidden; transition: opacity 0.2s ease;
  }
  .sidebar-overlay.open { display: block; opacity: 1; visibility: visible; }

  .nav-item { padding: 13px 14px; font-size: 14.5px; }

  .content { padding: 18px 14px 90px; max-width: 100%; }

  .view-header { flex-direction: column; align-items: stretch; }
  .view-header .btn { width: 100%; }

  /* Tabelas viram roláveis horizontalmente em vez de espremer colunas */
  .tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 16px; border-radius: var(--radius); }
  .tabela { margin-top: 0; min-width: 560px; }

  .row { flex-direction: column; gap: 10px; }
  .row label { min-width: 0; }

  .form-card { max-width: 100%; padding: 18px; }

  .modal-box { width: calc(100vw - 28px) !important; max-width: 440px; padding: 20px; }

  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  /* Inputs e botões com área de toque maior no touch */
  input, select, .btn { min-height: 40px; }
  .btn-sm { min-height: 32px; }
}

@media (max-width: 420px) {
  .modal-box { padding: 16px; }
  .escala-card .tags { gap: 5px; }
}


/* ---------- Forms / inputs ---------- */
label { font-size: 13px; color: var(--muted); }
input, select {
  font-size: 14px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); width: 100%; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.row { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 140px; }
.form-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; max-width: 480px; margin-top: 14px;
}
.form-card label { display: block; margin-bottom: 14px; }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fafbfc; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); margin: 0; }
.checkbox-list input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  border: none; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: filter 0.1s;
}
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--amber); color: #1B2430; }
.btn-primary:hover { background: var(--amber-dark); }
.btn-secondary { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Table ---------- */
.tabela { width: 100%; border-collapse: collapse; margin-top: 16px; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.tabela th, .tabela td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tabela th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; background: #FAFBFC; }
.tabela tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: #FBEFDD; color: var(--amber-dark); }
.badge-muted { background: #EEF0F3; color: var(--muted); }

/* ---------- Cards (dashboard) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .num { font-size: 26px; font-weight: 700; }
.card .label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Escalas list ---------- */
.lista-escalas { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.escala-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.escala-card h3 { margin: 0 0 4px; }
.escala-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tag { background: #EEF0F3; color: var(--text); font-size: 12px; padding: 3px 9px; border-radius: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,26,35,0.55); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--card); border-radius: 14px; padding: 26px 28px; width: 420px;
  max-height: 86vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.erro { color: var(--red); font-size: 13px; min-height: 18px; }
.aviso-box { background: #FBEFDD; border: 1px solid #F0D9AE; color: #7A5314; padding: 12px 14px; border-radius: 8px; margin-top: 14px; font-size: 13px; }
.sucesso-box { background: var(--green-bg); border: 1px solid #BFE3CF; color: var(--green); padding: 12px 14px; border-radius: 8px; margin-top: 14px; font-size: 13px; }
