:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-radius: 12px;
  --border-color: #334155;
  --brand-main: #3b82f6;
  --brand-hover: #2563eb;
  --status-positive: #10b981;
  --status-negative: #ef4444;
  --status-neutral: #94a3b8;
  --dioros-earth: #97623d;
  --dioros-olive: #95a790;
}

:root[data-theme="light"] {
  --bg-color: #eef3f9;
  --card-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --brand-main: #1d4ed8;
  --brand-hover: #1e40af;
  --status-positive: #047857;
  --status-negative: #b91c1c;
  --status-neutral: #475569;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 40px 20px;
  background: var(--bg-color);
  color: var(--text-main);
  font-family: "Poppins", sans-serif;
}

body[data-page="admin"] {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 30%),
    radial-gradient(circle at 82% 8%, rgba(149, 167, 144, 0.08), transparent 26%),
    linear-gradient(180deg, #172238 0%, #101827 100%);
}

body[data-page="admin"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(248, 250, 252, 0.9) 1px, transparent 0);
  background-size: 18px 18px;
}

:root[data-theme="light"] body {
  background:
    linear-gradient(180deg, rgba(29, 78, 216, 0.05), transparent 240px),
    var(--bg-color);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1250px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding: 24px 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-bg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body[data-page="admin"] .topbar {
  align-items: center;
  margin-bottom: 44px;
  padding: 26px 32px;
  border-color: rgba(180, 195, 216, 0.2);
  background: rgba(30, 41, 59, 0.68);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(14px);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.agency-logo {
  width: 86px;
  height: 74px;
  flex: 0 0 86px;
  object-fit: contain;
}

body[data-page="admin"] .agency-logo {
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.22));
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

body[data-page="admin"] .eyebrow {
  color: rgba(203, 213, 225, 0.72);
  letter-spacing: 0.7px;
}

h1, h2 {
  font-family: "Merriweather", serif;
}

h1 {
  margin: 0;
  font-size: 22px;
}

body[data-page="admin"] h1 {
  color: #eef4fb;
  font-size: 23px;
  line-height: 1.18;
}

.client-count {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

body[data-page="admin"] .client-count {
  color: rgba(148, 163, 184, 0.82);
}

h2 {
  margin: 0;
  font-size: 16px;
}

.field-label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

select,
.search-input {
  min-width: 210px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  background: var(--bg-color);
  color: var(--text-main);
  font: inherit;
}

body[data-page="admin"] .search-input {
  min-height: 44px;
  border-color: rgba(180, 195, 216, 0.2);
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.72), rgba(15, 23, 42, 0.52));
  color: #eef4fb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 220ms ease, box-shadow 220ms ease, background 220ms ease, transform 180ms ease;
}

body[data-page="admin"] .search-input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

body[data-page="admin"] .search-input:focus {
  border-color: rgba(147, 197, 253, 0.42);
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.admin-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.theme-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: transparent;
  color: var(--text-main);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

body[data-page="admin"] .theme-button {
  background: rgba(30, 41, 59, 0.52);
  transition: transform 180ms ease, border-color 220ms ease, color 220ms ease, box-shadow 220ms ease;
}

.theme-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-button:hover {
  border-color: var(--brand-main);
  color: var(--brand-main);
}

body[data-page="admin"] .theme-button:hover {
  border-color: rgba(149, 167, 144, 0.45);
  color: #bfdbfe;
  box-shadow: 0 0 0 4px rgba(149, 167, 144, 0.08);
}

body[data-page="admin"] .theme-button:active {
  transform: scale(0.96);
}

.primary-button {
  background: var(--brand-main);
}

.primary-button:hover {
  background: var(--brand-hover);
}

.secondary-button {
  border-color: var(--border-color);
  background: transparent;
  color: var(--text-main);
}

.secondary-button:hover {
  border-color: var(--brand-main);
}

.secondary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.secondary-link:hover {
  border-color: var(--brand-main);
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 80px);
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-bg);
}

.login-panel h1 {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form .search-input {
  width: 100%;
  border-color: #42526b;
  background: #0f172a;
  color: #f8fafc;
}

.password-field {
  position: relative;
  display: block;
}

.password-field .search-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b6c5d8;
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.12);
  outline: none;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.login-form .search-input:-webkit-autofill,
.login-form .search-input:-webkit-autofill:hover,
.login-form .search-input:-webkit-autofill:focus {
  border-color: #42526b;
  -webkit-box-shadow: 0 0 0 1000px #0f172a inset;
  -webkit-text-fill-color: #f8fafc;
  caret-color: #f8fafc;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--status-negative);
  font-size: 14px;
}

select:hover,
.search-input:focus {
  border-color: var(--brand-main);
}

.metric-cards,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 50px;
}

body[data-page="admin"] .admin-grid {
  gap: 24px;
}

.card,
.client-card,
.table-card,
.chart-card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body[data-page="admin"] .client-card {
  border-color: rgba(180, 195, 216, 0.2);
  background:
    linear-gradient(180deg, rgba(38, 52, 74, 0.92), rgba(24, 35, 56, 0.9));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, background 220ms ease;
}

.card:hover,
.client-card:hover,
.table-card:hover,
.chart-card:hover {
  transform: translateY(-6px);
  border-color: var(--brand-main);
  box-shadow: 0 12px 25px rgba(59, 130, 246, 0.15);
}

body[data-page="admin"] .client-card:hover {
  transform: translateY(-3px);
  border-color: rgba(147, 197, 253, 0.35);
  background:
    linear-gradient(180deg, rgba(45, 60, 84, 0.96), rgba(27, 39, 61, 0.95));
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.22);
}

body[data-page="admin"] .client-card:active {
  transform: translateY(-1px) scale(0.99);
}

.card {
  min-height: 148px;
  padding: 24px;
}

.empty-dashboard {
  grid-column: 1 / -1;
  padding: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-bg);
  color: var(--text-muted);
}

.empty-dashboard h2 {
  margin-bottom: 8px;
  color: var(--text-main);
  font-family: "Poppins", sans-serif;
  font-size: 18px;
}

.empty-dashboard p {
  margin: 0;
  line-height: 1.6;
}

.loading-grid .card,
.loading-grid .chart-card {
  pointer-events: none;
}

.skeleton-card,
.skeleton-chart {
  position: relative;
  overflow: hidden;
}

.skeleton-card::before,
.skeleton-chart::before {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.16), transparent),
    linear-gradient(var(--border-color), var(--border-color));
  background-size: 180px 100%, 100% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  opacity: 0.45;
}

.skeleton-chart {
  min-height: 330px;
}

@keyframes shimmer {
  from { background-position: -180px 0, 0 0; }
  to { background-position: 220px 0, 0 0; }
}

.card-title {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.card-value {
  color: var(--text-main);
  font-size: 32px;
  font-weight: 600;
}

.card-diff {
  min-height: 22px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}

.diff-positive { color: var(--status-positive); }
.diff-negative { color: var(--status-negative); }
.diff-neutral { color: var(--status-neutral); font-weight: 500; }

.client-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

body[data-page="admin"] .client-card {
  min-height: 150px;
  align-content: space-between;
  padding: 24px;
}

body[data-page="admin"] .client-card h2 {
  color: #edf3fa;
  font-size: 17px;
  line-height: 1.32;
}

.client-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

body[data-page="admin"] .client-card p {
  margin-top: 7px;
  color: rgba(148, 163, 184, 0.78);
}

.client-kind {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.35;
}

body[data-page="admin"] .client-kind {
  color: rgba(191, 219, 254, 0.68);
}

.client-meta {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
}

.client-meta-label {
  color: rgba(203, 213, 225, 0.72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.client-meta strong {
  color: #bfdbfe;
  font-size: 15px;
  font-weight: 700;
}

.client-meta .client-meta-date {
  font-size: 14px;
  line-height: 1.2;
}

.client-meta-duration {
  color: rgba(203, 213, 225, 0.78);
  font-weight: 500;
}

.client-card a {
  width: fit-content;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

body[data-page="admin"] .client-card a {
  border-color: rgba(180, 195, 216, 0.24);
  background: rgba(15, 23, 42, 0.16);
  color: #dbeafe;
  transition: transform 180ms ease, border-color 220ms ease, color 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.client-card a:hover {
  border-color: var(--brand-main);
  color: var(--brand-main);
}

body[data-page="admin"] .client-card a:hover {
  border-color: rgba(149, 167, 144, 0.5);
  background: rgba(59, 130, 246, 0.08);
  color: #f8fafc;
  box-shadow: inset 0 0 18px rgba(59, 130, 246, 0.08);
}

body[data-page="admin"] .client-card a:active {
  transform: scale(0.98);
}

.table-card {
  margin-bottom: 50px;
  padding: 32px;
  cursor: pointer;
}

.table-card.is-empty {
  cursor: default;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.section-header span {
  color: var(--text-muted);
  font-size: 12px;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

th {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  text-align: left;
}

body[data-page="client"] td:first-child strong,
body[data-page="client"] #monthSelect {
  font-family: "Merriweather", serif;
  font-weight: 400;
}

body[data-page="client"] th:first-child {
  color: #93c5fd;
}

body[data-page="client"] td:first-child {
  background: rgba(59, 130, 246, 0.04);
}

body[data-page="client"] td:first-child strong {
  color: #bfdbfe;
  font-size: 14px;
  line-height: 1.45;
}

body[data-page="client"] #monthSelect {
  color: #bfdbfe;
}

tr:hover td {
  background: rgba(59, 130, 246, 0.05);
}

:root[data-theme="light"] .topbar,
:root[data-theme="light"] .card,
:root[data-theme="light"] .client-card,
:root[data-theme="light"] .table-card,
:root[data-theme="light"] .chart-card,
:root[data-theme="light"] .login-panel,
:root[data-theme="light"] .modal-content {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] tr:hover td {
  background: rgba(29, 78, 216, 0.06);
}

:root[data-theme="light"] .modal-overlay {
  background: rgba(226, 232, 240, 0.82);
}

.charts-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.chart-card {
  padding: 24px;
  cursor: pointer;
}

.chart-card h2 {
  margin-bottom: 20px;
  font-family: "Poppins", sans-serif;
  font-size: 16px;
  font-weight: 500;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 260px;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.85);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: 75vh;
  padding: 30px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--card-bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-content-table {
  height: auto;
  max-height: 85vh;
}

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

.icon-button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--status-negative);
}

.modal-chart-container {
  position: relative;
  flex: 1;
  width: 100%;
}

.error-state {
  padding: 30px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-bg);
  color: var(--text-muted);
}

body[data-page="admin"] ::selection {
  background: rgba(151, 98, 61, 0.36);
}

body[data-page="admin"]::-webkit-scrollbar {
  width: 10px;
}

body[data-page="admin"]::-webkit-scrollbar-track {
  background: #101827;
}

body[data-page="admin"]::-webkit-scrollbar-thumb {
  border: 2px solid #101827;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
}

body[data-page="admin"]::-webkit-scrollbar-thumb:hover {
  background: rgba(149, 167, 144, 0.45);
}

:root[data-theme="light"] body[data-page="admin"] {
  background:
    linear-gradient(180deg, #f6f8fb 0%, #e8eef6 100%);
}

:root[data-theme="light"] body[data-page="admin"]::before {
  opacity: 0.01;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.9) 1px, transparent 0);
}

:root[data-theme="light"] body[data-page="admin"] .topbar,
:root[data-theme="light"] body[data-page="admin"] .client-card {
  border-color: rgba(100, 116, 139, 0.28);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(30, 41, 59, 0.1);
}

:root[data-theme="light"] body[data-page="admin"] h1,
:root[data-theme="light"] body[data-page="admin"] .client-card h2 {
  color: #0f172a;
}

:root[data-theme="light"] body[data-page="admin"] .eyebrow {
  color: #64748b;
}

:root[data-theme="light"] body[data-page="admin"] .client-count {
  color: #475569;
}

:root[data-theme="light"] body[data-page="admin"] .search-input {
  border-color: #b8c4d4;
  background: #ffffff;
  color: #0f172a;
}

:root[data-theme="light"] body[data-page="admin"] .search-input::placeholder {
  color: #718096;
}

:root[data-theme="light"] body[data-page="admin"] .theme-button {
  border-color: #b8c4d4;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 18px rgba(30, 41, 59, 0.1);
}

:root[data-theme="light"] body[data-page="admin"] .theme-button:hover {
  border-color: #1d4ed8;
  color: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}

:root[data-theme="light"] body[data-page="admin"] .client-meta-label {
  color: #64748b;
}

:root[data-theme="light"] body[data-page="admin"] .client-kind {
  color: #64748b;
}

:root[data-theme="light"] body[data-page="admin"] .client-meta strong {
  color: #1d4ed8;
}

:root[data-theme="light"] body[data-page="admin"] .client-meta-duration {
  color: #475569;
}

:root[data-theme="light"] body[data-page="admin"] .client-card a {
  border-color: #d7e0ec;
  background: #f8fbff;
  color: #1d4ed8;
}

:root[data-theme="light"] .login-form .search-input {
  border-color: #b8c4d4;
  background: #ffffff;
  color: #0f172a;
}

:root[data-theme="light"] .password-toggle {
  color: #475569;
}

:root[data-theme="light"] .password-toggle:hover,
:root[data-theme="light"] .password-toggle:focus-visible {
  color: #0f172a;
  background: rgba(29, 78, 216, 0.08);
}

:root[data-theme="light"] .login-form .search-input:-webkit-autofill,
:root[data-theme="light"] .login-form .search-input:-webkit-autofill:hover,
:root[data-theme="light"] .login-form .search-input:-webkit-autofill:focus {
  border-color: #b8c4d4;
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
  -webkit-text-fill-color: #0f172a;
  caret-color: #0f172a;
}

:root[data-theme="light"] body[data-page="client"] th:first-child,
:root[data-theme="light"] body[data-page="client"] td:first-child strong,
:root[data-theme="light"] body[data-page="client"] #monthSelect {
  color: #1d4ed8;
}

:root[data-theme="light"] body[data-page="client"] td:first-child {
  background: rgba(29, 78, 216, 0.06);
}

@media (max-width: 900px) {
  body { padding: 24px 14px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 22px; }
  .admin-brand { align-items: flex-start; }
  .agency-logo { width: 72px; height: 64px; flex-basis: 72px; }
  .admin-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .theme-button { align-self: flex-start; }
  .charts-container { grid-template-columns: 1fr; }
  select, .search-input { width: 100%; min-width: 0; }
}
