:root {
  --bg: #0f1419;
  --header-bg: rgba(15, 20, 25, 0.88);
  --surface: #161d26;
  --surface-2: #1f2937;
  --border: #2a3646;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-text: #082f49;
  --primary-bg: rgba(56, 189, 248, 0.14);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --rose: #fb7185;
  --rose-bg: rgba(251, 113, 133, 0.14);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.14);
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] {
  --bg: #f4f6f9;
  --header-bg: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-text: #ffffff;
  --primary-bg: rgba(2, 132, 199, 0.12);
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.12);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.12);
  --rose: #e11d48;
  --rose-bg: rgba(225, 29, 72, 0.12);
  --purple: #7c3aed;
  --purple-bg: rgba(124, 58, 237, 0.12);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.brand h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 700;
}

.sync-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  border-color: #3b4c66;
  background: #253349;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  font-weight: 600;
}

.btn-primary:hover {
  opacity: 0.9;
  background: var(--primary);
  border-color: var(--primary);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Banner de configuração ou erro */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.banner-info {
  background: var(--primary-bg);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.banner-warn {
  background: var(--amber-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Barra de Atalhos Rápidos */
.shortcuts-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.section-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-bar-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.shortcuts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shortcut-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  transition: border-color 0.15s, transform 0.1s;
}

.shortcut-chip:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.shortcut-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.shortcut-del {
  margin-left: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 6px;
}

.shortcut-del:hover {
  color: var(--rose);
  background: var(--rose-bg);
}

/* Faixa Hoje & Prazos */
.today-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
}

.stat-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Grid Principal Balanceado (2 em cima + 3 embaixo no PC, zero buraco) */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-grid > .card:nth-child(1),
.dashboard-grid > .card:nth-child(2) {
  grid-column: span 3;
}

.dashboard-grid > .card:nth-child(3),
.dashboard-grid > .card:nth-child(4),
.dashboard-grid > .card:nth-child(5) {
  grid-column: span 2;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-grid > .card:nth-child(n) {
    grid-column: span 1;
  }
  .dashboard-grid > .card:nth-child(5) {
    grid-column: span 2;
  }
}

@media (max-width: 700px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-grid > .card:nth-child(n) {
    grid-column: span 1;
  }
  .app-header {
    padding: 10px 14px;
  }
  .container {
    padding: 12px 12px 76px;
  }
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 35;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 8px;
    justify-content: space-around;
    gap: 4px;
  }
  .mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 2px;
    border-radius: 8px;
  }
  .mobile-nav a:active {
    background: var(--surface-2);
    color: var(--primary);
  }
  .toast {
    bottom: 72px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 290px;
  max-height: 460px;
  scroll-margin-top: 72px;
}

.card-header {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.96rem;
  font-weight: 650;
  margin: 0;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 6px 10px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.card-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
}

.item-title.done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
}

.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-rose { background: var(--rose-bg); color: var(--rose); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 28px 12px;
}

.suggestion-box {
  background: var(--amber-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.88rem;
  outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}

.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
