@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg: #faf7f0;
  --surface: rgba(255, 253, 248, 0.88);
  --surface-solid: #fffdf8;
  --surface-2: #f2eadf;
  --border: rgba(123, 81, 50, 0.12);
  --text: #2f2924;
  --muted: #786d64;
  --primary: #7b5132;       /* Nobre marrom */
  --primary-2: #5d3c25;
  --primary-soft: #f8efe4;
  --accent: #c68642;        /* Caramelo premium */
  --accent-soft: #fbf5ed;
  --success: #77815c;       /* Verde oliva */
  --success-soft: #e3e8d7;
  --warning: #df8752;       /* Laranja terroso */
  --warning-soft: #f6d8c7;
  --danger: #b94a3f;        /* Vermelho ferrugem */
  --danger-soft: #ffe1dc;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow-sm: 0 4px 12px rgba(83, 58, 34, 0.04);
  --shadow: 0 16px 35px rgba(83, 58, 34, 0.08);
  --shadow-lg: 0 24px 50px rgba(83, 58, 34, 0.12);
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: radial-gradient(circle at top left, #f4e5d2, transparent 40%), linear-gradient(135deg, #fbf7ef, #f7f3eb 55%, #f4efe7);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent);
}

/* ---------------- Layout (Sidebar + Main) ---------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 10px 28px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--warning));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 8px 20px rgba(198, 134, 66, 0.3);
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.5px;
  color: var(--primary);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

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

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.25s ease;
  border-left: 4px solid transparent;
}

.sidebar nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
  transform: translateX(3px);
}

.sidebar nav a.active {
  background: var(--primary-soft);
  color: var(--primary-2);
  border-left-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.sidebar nav .ico {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.main {
  margin-left: 280px;
  padding: 34px 44px;
  max-width: 1540px;
}

@media(max-width: 1024px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
    inset: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand {
    padding: 0 12px 0 0;
  }
  .brand-sub, .sidebar-foot {
    display: none;
  }
  .sidebar nav {
    flex-direction: row;
    gap: 4px;
  }
  .sidebar nav a {
    padding: 8px 12px;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px;
    white-space: nowrap;
  }
  .sidebar nav a.active {
    border-bottom-color: var(--accent);
  }
  .main {
    margin-left: 0;
    padding: 24px;
  }
}

/* ---------------- Page Elements ---------------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 900;
  color: var(--primary-2);
  letter-spacing: -0.8px;
  line-height: 1.15;
}

.page-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 4px;
  font-weight: 500;
}

/* ---------------- Panels and Cards (Glassmorphism) ---------------- */
.panel {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.panel:hover {
  border-color: rgba(198, 134, 66, 0.25);
  box-shadow: var(--shadow-lg);
}

.panel-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
}

.panel-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background: linear-gradient(to bottom, var(--accent), var(--warning));
  border-radius: 2px;
}

/* KPIs / Stats Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(198, 134, 66, 0.3);
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(198, 134, 66, 0.06);
  pointer-events: none;
}

.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 800;
}

.kpi-value {
  font-size: clamp(22px, 1.8vw, 28px);
  font-weight: 900;
  color: var(--primary-2);
  margin-top: 10px;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 600;
}

/* ---------------- Form Elements ---------------- */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input, input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-weight: 600;
}

.input:focus, input[type=text]:focus, input[type=email]:focus, input[type=password]:focus, input[type=date]:focus, input[type=number]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--warning-soft);
  background: #fff;
}

.field {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 14.5px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--primary-2);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 8px 20px rgba(123, 81, 50, 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-2), var(--accent));
  box-shadow: 0 12px 28px rgba(123, 81, 50, 0.25);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, var(--success), var(--accent));
  color: #fff;
  box-shadow: 0 8px 20px rgba(119, 129, 92, 0.15);
}

.btn-success:hover {
  filter: brightness(1.05);
  box-shadow: 0 12px 28px rgba(119, 129, 92, 0.25);
  color: #fff;
}

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

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

.btn-ghost:hover {
  background: var(--primary-soft);
  color: var(--primary-2);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* ---------------- Data Tables ---------------- */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 14px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-solid);
}

.table th, .table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--primary-soft);
  font-weight: 800;
  color: var(--primary-2);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.table tr:hover td {
  background: var(--primary-soft);
}

.table td.num {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------------- Badges & Statuses ---------------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-2);
  color: var(--muted);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------------- Progress Bar ---------------- */
.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 4px;
}

/* ---------------- Interactive Dashboard Grid ---------------- */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.chart-wrap {
  height: 280px;
  position: relative;
  margin-top: 10px;
}

@media(max-width: 900px) {
  .dash-grid-2, .dash-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Auditing & Insights ---------------- */
.audit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.audit-item {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.audit-item b {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.audit-item span {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-2);
}

.insights-list {
  padding-left: 20px;
  margin-top: 14px;
}

.insights-list li {
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--text);
}

/* ---------------- Drag & Drop File Zone ---------------- */
.drop-zone {
  border: 2.5px dashed var(--accent);
  border-radius: var(--radius);
  padding: 38px 24px;
  text-align: center;
  background: var(--accent-soft);
  cursor: pointer;
  transition: all 0.25s ease;
  margin-bottom: 18px;
}

.drop-zone:hover {
  background: var(--warning-soft);
  border-color: var(--warning);
}

.drop-icon {
  font-size: 38px;
  margin-bottom: 10px;
}

.drop-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-2);
}

.drop-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ---------------- Flash Messages ---------------- */
.flash {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
}

.flash-info {
  background: var(--primary-soft);
  color: var(--primary-2);
  border-color: var(--border);
}

.flash-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(119, 129, 92, 0.2);
}

.flash-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(185, 74, 63, 0.2);
}

/* ---------------- Login Card Specific ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(900px 500px at 10% 10%, var(--warning-soft), transparent 60%), radial-gradient(700px 400px at 90% 90%, var(--success-soft), transparent 60%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 34px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 18px 0 6px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--primary-2);
}

.login-card p.sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 24px;
  font-weight: 500;
}

/* Project Seletor Widget in Header */
.proj-selector-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.proj-selector-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.proj-selector {
  border: none;
  background: transparent;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--primary-2);
  padding: 0;
  cursor: pointer;
  outline: none;
  font-family: var(--font);
}

.proj-selector:focus {
  box-shadow: none;
}
