:root {
  --primary: #0f766e;
  --primary-dark: #0b4f4a;
  --accent: #c7a35a;
  --danger: #b42318;
  --bg: #f4f1ea;
  --card: #fffdf8;
  --card-soft: #f8f5ee;
  --border: #ded6c8;
  --border-strong: #b9ad99;
  --text: #17201f;
  --muted: #6d675d;
  --shadow: 0 22px 54px rgba(35, 30, 20, 0.13);
  --shadow-sm: 0 10px 28px rgba(35, 30, 20, 0.09);
  --ring: 0 0 0 4px rgba(15, 118, 110, 0.17);
  --radius: 8px;
}

body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(180deg, rgba(22, 32, 31, 0.08), transparent 230px),
    linear-gradient(90deg, rgba(199, 163, 90, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(22, 32, 31, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 32px 32px, 32px 32px, auto;
  color: var(--text);
}

/* Nav */
nav {
  height: 66px;
  padding: 0 28px;
  color: #fffdf8;
  background:
    linear-gradient(135deg, rgba(11, 17, 16, 0.98), rgba(22, 32, 31, 0.94)),
    #16201f;
  border-bottom: 1px solid rgba(199, 163, 90, 0.28);
  box-shadow: 0 16px 34px rgba(11, 17, 16, 0.22);
  backdrop-filter: blur(18px);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fffdf8;
  font-size: 1rem;
  letter-spacing: 0;
}

.nav-brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #f1d78d 48%, var(--primary));
  box-shadow: 0 0 0 4px rgba(199, 163, 90, 0.14);
}

.nav-links {
  gap: 8px;
}

.nav-links a,
#btn-logout {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  color: rgba(255, 253, 248, 0.72);
  padding: 8px 12px;
  font-weight: 650;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.nav-links a:hover {
  color: #fffdf8;
  background: rgba(255, 253, 248, 0.09);
}

.nav-links a.active {
  color: #12201f;
  background: linear-gradient(135deg, #f1d78d, var(--accent));
  box-shadow: 0 10px 24px rgba(199, 163, 90, 0.24);
}

#nav-user {
  max-width: 220px;
  color: rgba(255, 253, 248, 0.68);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#btn-logout {
  border: 1px solid rgba(255, 253, 248, 0.18);
  background: rgba(255, 253, 248, 0.07);
  color: rgba(255, 253, 248, 0.86);
}

#btn-logout:hover {
  color: #fff;
  border-color: rgba(180, 35, 24, 0.36);
  background: rgba(180, 35, 24, 0.18);
}

/* Layout */
#app {
  max-width: 1180px;
  padding: 36px 24px 46px;
}

.page-header {
  margin-bottom: 18px;
}

h2,
.page-header h2 {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 760;
  letter-spacing: 0;
}

.page-header h2::after,
main > h2::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

/* Cards, forms, controls */
.auth-box,
.inline-form,
#cost-form-wrapper,
.report-filters,
.chart-section,
.stat-card,
table {
  border: 1px solid rgba(222, 214, 200, 0.92);
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow-sm);
}

.auth-box {
  margin-top: 96px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(248, 245, 238, 0.96)),
    var(--card);
}

.auth-box h1 {
  color: var(--text);
  letter-spacing: 0;
}

.subtitle {
  color: var(--muted);
}

.inline-form,
#cost-form-wrapper,
.report-filters {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(248, 245, 238, 0.96));
}

input,
select,
textarea {
  background: #fffdf8;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.auth-form input,
.auth-form select,
.inline-form input,
.form-row input,
.form-row select,
.form-row textarea,
.report-filters select,
.report-filters input {
  min-height: 40px;
  border-color: var(--border);
  background: #fffdf8;
}

.auth-form input:focus,
.inline-form input:focus,
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
.report-filters select:focus,
.report-filters input:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.form-row label,
.report-filters label {
  color: #635d54;
  font-size: 0.82rem;
  font-weight: 720;
}

button,
.sso-button,
#btn-add-cost,
.inline-form button,
.form-actions button,
.report-filters button {
  transition: transform 140ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.sso-button,
#btn-add-cost,
.auth-form button[type=submit],
.inline-form button[type=submit],
.form-actions button[type=submit],
.report-filters button[type=submit],
.payment-upload button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #159386);
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.23);
}

.sso-button:hover,
#btn-add-cost:hover,
.auth-form button[type=submit]:hover,
.inline-form button[type=submit]:hover,
.form-actions button[type=submit]:hover,
.report-filters button[type=submit]:hover,
.payment-upload button:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

#btn-cancel-cost,
#btn-cancel-ai-tool,
#btn-reset-stats,
#btn-reset-team {
  border: 1px solid var(--border);
  background: #fffdf8;
  color: var(--muted);
}

#btn-cancel-cost:hover,
#btn-cancel-ai-tool:hover,
#btn-reset-stats:hover,
#btn-reset-team:hover {
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* Tables */
table {
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

th {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f3eee4, #e8dfcf);
  color: #635d54;
  font-size: 0.75rem;
  font-weight: 780;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

td {
  color: #2b3432;
  border-top: 0;
  border-bottom: 1px solid #eee7dc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #fbf7ef;
}

td code {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--primary-dark);
  padding: 3px 7px;
  font-size: 0.78rem;
}

td img {
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(35, 30, 20, 0.12);
}

.file-link {
  color: var(--primary);
}

.status-badge {
  letter-spacing: 0.035em;
}

.status-new {
  border-color: rgba(199, 163, 90, 0.42);
  background: #fff7df;
  color: #8b650f;
}

.status-paid {
  border-color: rgba(15, 118, 110, 0.32);
  background: #e7f6f2;
  color: #0b665f;
}

.btn-edit,
.btn-edit-ai-tool,
.btn-delete,
.btn-delete-ai-tool,
.btn-delete-team {
  min-height: 30px;
  border-radius: 6px;
  font-weight: 700;
}

.btn-edit,
.btn-edit-ai-tool {
  background: #fffdf8;
}

.btn-delete,
.btn-delete-ai-tool,
.btn-delete-team {
  background: #fffdf8;
}

.btn-edit:hover,
.btn-edit-ai-tool:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(15, 118, 110, 0.07);
}

.btn-delete:hover,
.btn-delete-ai-tool:hover,
.btn-delete-team:hover {
  background: #fff1ef;
}

/* Stats */
.stats-grid {
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.98), rgba(244, 234, 210, 0.52)),
    var(--card);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.stat-card .label {
  color: var(--muted);
  font-weight: 700;
}

.stat-card .value {
  color: var(--primary-dark);
  letter-spacing: 0;
}

.monthly-report-section,
.stats-section {
  margin-top: 28px;
}

.monthly-report-section h3,
.stats-section h3,
.chart-header h3 {
  color: #635d54;
  font-size: 0.82rem;
  font-weight: 800;
}

.report-filters {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(150px, 0.8fr) auto auto;
}

#team-filter-form {
  grid-template-columns: minmax(180px, 240px) auto auto minmax(0, 1fr);
}

.chart-section {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(248, 245, 238, 0.96));
  box-shadow: var(--shadow-sm);
}

.chart-header p {
  color: var(--muted);
}

/* Mobile */
@media (max-width: 760px) {
  nav {
    padding: 12px;
  }

  .nav-toggle {
    background: linear-gradient(135deg, var(--accent), #f1d78d);
    color: #12201f;
    box-shadow: 0 10px 24px rgba(199, 163, 90, 0.22);
  }

  .nav-links {
    padding: 12px;
    border: 1px solid rgba(199, 163, 90, 0.28);
    border-radius: var(--radius);
    background: rgba(22, 32, 31, 0.98);
    box-shadow: var(--shadow);
  }

  .nav-links a,
  #btn-logout {
    background: rgba(255, 253, 248, 0.08);
    color: rgba(255, 253, 248, 0.9);
    border: 1px solid rgba(255, 253, 248, 0.14);
  }

  .nav-links a.active {
    color: #12201f;
    border-color: transparent;
  }

  #nav-user {
    color: rgba(255, 253, 248, 0.72);
  }

  #app {
    padding: 22px 12px 34px;
  }

  .report-filters {
    grid-template-columns: 1fr;
  }

  #team-filter-form {
    grid-template-columns: 1fr;
  }

  tr {
    background: #fffdf8;
    box-shadow: var(--shadow-sm);
  }

  td {
    border-bottom: 0;
    border-top: 1px solid #eee7dc;
  }

  td::before {
    color: #71695e;
  }
}
