:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --soft: #334155;
  --line: #243041;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #f97316;
  --primary-2: #fb923c;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
  --shadow: 0 12px 30px rgba(0,0,0,.25);
  --radius: 18px;
}

/* ─── TEMA CLARO ─── */
[data-theme="light"] {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --soft: #cbd5e1;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #f97316;
  --primary-2: #fb923c;
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
  --blue: #0284c7;
  --shadow: 0 12px 30px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.login-wrapper {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.54);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.login-card {
  width: min(780px, 92vw);
  max-width: 920px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 28px 60px rgba(0,0,0,.35);
  background: #f5f6fa;
  border: 1px solid rgba(207,217,235,.6);
}
.login-left,
.login-right {
  padding: 32px;
}
.login-left {
  background: #fff;
}
.login-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.login-head .logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-content: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #f97316, #fb923c);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.login-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
}
.login-head p {
  margin: 0;
  color: #7c859e;
}
.login-error {
  margin-bottom: 14px;
  border: 1px solid #f87171;
  color: #b91c1c;
  background: #fee2e2;
  padding: 10px 12px;
  border-radius: 10px;
}
.login-right {
  position: relative;
  background: linear-gradient(145deg, #0f1b49 0%, #1a2a70 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-right h3 {
  margin-top: 0;
  font-size: 28px;
  color: #f8fafc;
}
.login-right p {
  color: rgba(248,249,252,.95);
  line-height: 1.56;
  margin-top: 14px;
  font-size: 1rem;
}
.login-right::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(135deg, rgba(0,0,0,.26), rgba(0,0,0,.4));
}
.login-right * {
  position: relative;
  z-index: 1;
}
.login-left input,
.login-left select,
.login-left textarea {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid rgba(143,155,179,.4);
  background: rgba(255,255,255,.85);
  color: #0f172a;
  border-radius: 10px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.login-left input:focus,
.login-left select:focus,
.login-left textarea:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
  outline: none;
}
.login-left .btn.primary {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(249,115,22,.4);
}
.login-left .btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(249,115,22,.45);
}
.login-left .btn.secondary {
  font-size: 14px;
  color: #334155;
  text-align: center;
}

@media (max-width: 860px) {
  .login-card {
    grid-template-columns: 1fr;
    border-radius: 0;
    margin: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    box-shadow: none;
    border: none;
  }
  .login-right {
    display: none;
  }
  .login-left {
    background: rgba(255,255,255,.92);
    padding: 24px;
  }
  .login-wrapper {
    align-items: flex-start;
    padding: 16px 0;
  }
}
.login-wrapper.show {
  display: flex;
}
.login-box {
  width: min(420px, 96vw);
  background: var(--panel);
  padding: 24px;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-box h2 {
  margin: 0 0 10px;
}
.login-box .form-grid {
  display: grid;
  gap: 12px;
}
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: var(--text);
  transition: background-color .3s ease, color .3s ease;
}
.login-wrapper {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, .9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 30px;
}
.login-wrapper.show {
  display: flex;
  animation: fadeInLogin 0.3s ease;
}
@keyframes fadeInLogin {
  from { opacity: 0; transform: translateY(-15px); }
  to { opacity: 1; transform: translateY(0); }
}

[data-theme="light"] body {
  background: linear-gradient(180deg, #f0f4f8 0%, #f8fafc 100%);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(10, 15, 25, .88);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(12px);
  transition: background-color .3s ease, border-color .3s ease;
}

[data-theme="light"] .sidebar {
  background: rgba(248, 250, 252, .92);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(249,115,22,.16), rgba(251,146,60,.05));
  border: 1px solid rgba(249,115,22,.22);
}

.brand-badge {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav button {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: .2s ease;
}

.nav button:hover,
.nav button.active {
  background: rgba(249,115,22,.12);
  border-color: rgba(249,115,22,.2);
  color: #fff;
  transform: translateX(2px);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h2 { margin: 0; font-size: 28px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.2); }

.grid {
  display: grid;
  gap: 18px;
}

.cards {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  margin-bottom: 22px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: background-color .3s ease, border-color .3s ease;
}

.metric-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 800; }
.metric-help { color: var(--muted); font-size: 12px; margin-top: 8px; }

.two-col { grid-template-columns: 1.4fr 1fr; }
.hidden { display: none !important; }

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-header h3 { margin: 0; font-size: 18px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

input, select, textarea {
  width: 100%;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: #ffffff;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(249,115,22,.6);
  box-shadow: 0 0 0 4px rgba(249,115,22,.12);
}

.search { min-width: 280px; flex: 1; }

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  text-align: left;
  vertical-align: top;
}

th { color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--panel-2); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.tag.ativo { background: rgba(34,197,94,.15); color: var(--green); }
.tag.atrasado { background: rgba(239,68,68,.15); color: var(--red); }
.tag.finalizado { background: rgba(56,189,248,.15); color: var(--blue); }
.tag.pendente { background: rgba(245,158,11,.15); color: var(--yellow); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-grid .full { grid-column: 1 / -1; }

.empty {
  border: 1px dashed var(--soft);
  border-radius: 16px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-2);
  transition: background-color .3s ease, border-color .3s ease;
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--panel-2);
  transition: background-color .3s ease, border-color .3s ease;
}

.list-item strong { display: block; margin-bottom: 6px; }
.muted { color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  backdrop-filter: blur(6px);
}

.modal.show { display: flex; }

.modal-box {
  width: min(820px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-height: 92vh;
  overflow: auto;
  transition: background-color .3s ease, border-color .3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.alert {
  border: 1px solid rgba(245,158,11,.24);
  background: rgba(245,158,11,.08);
  color: var(--yellow);
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 14px;
  transition: color .3s ease, background-color .3s ease;
}

.footer-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .cards, .two-col { grid-template-columns: 1fr 1fr; }
}

/* MOBILE APP STYLE: altera apenas a experiência mobile, mantendo a web intacta */
.mobile-theme-toggle { display:none; }

@media (max-width: 860px) {
  .mobile-theme-toggle {
    display: block;
    width: calc(100% - 20px);
    margin: 8px auto 12px;
    text-align: center;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  body {
    background: var(--bg);
  }

  .app {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    z-index: 40;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--line);
    background: rgba(8, 12, 22, .96);
    backdrop-filter: blur(18px);
    box-shadow: 0 -12px 30px rgba(0,0,0,.35);
  }

  .brand {
    display: none;
  }

  .nav {
    flex-direction: row;
    gap: 8px;
    justify-content: space-between;
  }

  .nav button {
    min-width: 0;
    flex: 1;
    text-align: center;
    font-size: 11px;
    line-height: 1.2;
    padding: 10px 6px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
  }

  .nav button:hover,
  .nav button.active {
    transform: none;
    background: linear-gradient(180deg, rgba(249,115,22,.24), rgba(249,115,22,.08));
    border-color: rgba(249,115,22,.25);
  }

  .main {
    padding: 16px 14px 110px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: -16px -14px 18px;
    padding: 14px 14px 12px;
    background: rgba(11,18,32,.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(36,48,65,.7);
    align-items: stretch;
  }

  .topbar > div:first-child {
    width: 100%;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 13px;
  }

  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .actions .btn,
  .actions label.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 12px 10px;
    font-size: 13px;
  }

  #openQuickAdd {
    position: fixed;
    right: 16px;
    bottom: 84px;
    z-index: 45;
    min-width: auto;
    border-radius: 999px;
    padding: 14px 18px;
    box-shadow: 0 12px 24px rgba(0,0,0,.35);
  }

  .cards,
  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .card {
    border-radius: 20px;
    padding: 16px;
  }

  .metric-value {
    font-size: 24px;
  }

  .panel-header {
    align-items: flex-start;
  }

  .panel-header .btn {
    width: 100%;
  }

  .toolbar {
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-2);
    overflow: hidden;
  }

  td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    display: block;
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 94dvh;
    border-radius: 24px 24px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .modal-header {
    position: sticky;
    top: 0;
    background: #0f172a;
    padding-bottom: 10px;
    z-index: 2;
  }

  [data-theme="light"] .modal-header {
    background: var(--panel);
  }
}

@media (max-width: 600px) {
  .topbar .actions {
    display: none !important;
  }
}
