* {
  box-sizing: border-box;
}

:root {
  --bg-main: #e4e8ee;
  --bg-secondary: #5b6673;
  --card-bg: #ffffff;
  --card-border: #d4dbe4;
  --text-main: #252f3e;
  --text-muted: #6b7688;
  --accent: #1fbcb4;
  --accent-strong: #179f98;
  --danger: #d74e4e;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 14% 12%, rgba(53, 143, 255, 0.18) 0%, transparent 24%),
    radial-gradient(circle at 86% 20%, rgba(70, 229, 206, 0.14) 0%, transparent 26%),
    radial-gradient(circle at 50% 120%, rgba(129, 86, 255, 0.22) 0%, transparent 36%),
    var(--bg-main);
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    radial-gradient(rgba(110, 154, 255, 0.18) 1px, transparent 1px);
  background-size:
    120px 120px,
    180px 180px;
  background-position:
    0 0,
    30px 45px;
  opacity: 0.25;
  z-index: 0;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 16px 22px;
  position: relative;
  z-index: 1;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 0;
}

.user-avatar-frame {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid #ccd3e0;
  background: #f4f6fb;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.user-avatar-frame #user-avatar-initials {
  color: #7a8599;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1;
  text-transform: uppercase;
}

.user-avatar-frame.has-photo img {
  display: block;
}

.user-avatar-frame.has-photo #user-avatar-initials {
  display: none;
}

h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.gold-title {
  font-size: 1em;
  color: #5ce5cd;
  background: linear-gradient(
    115deg,
    #2ea99d 0%,
    #51d8cb 28%,
    #b0fff7 48%,
    #51d8cb 62%,
    #2ea99d 100%
  );
  background-size: 220% auto;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: goldSheen 5s ease-in-out infinite;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
  align-items: flex-end;
  padding-top: 6px;
}

.tab-btn {
  border: 1px solid rgba(66, 205, 196, 0.55);
  background: rgba(20, 30, 56, 0.7);
  color: #8cefe8;
  border-radius: 12px 12px 0 0;
  border-bottom: 0;
  margin-bottom: -1px;
  box-shadow: inset 0 0 0 1px rgba(132, 226, 218, 0.1);
}

.tab-btn-active {
  background: linear-gradient(180deg, rgba(66, 205, 196, 0.34), rgba(37, 146, 169, 0.32));
  color: #dffffa;
  border-color: rgba(102, 243, 234, 0.75);
}

#tab-input-panel > .card:first-child,
#tab-forecast-panel > .card:first-child {
  margin-top: 0;
  border-top-left-radius: 0;
}

.subtitle {
  margin-top: 0;
  color: #5d6578;
}

.card {
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--card-border);
  box-shadow:
    0 18px 34px rgba(4, 8, 18, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 20px;
  backdrop-filter: blur(5px);
}

.purchases-card {
  margin-top: 18px;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-title-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(130, 237, 228, 0.45));
}

.limits-card {
  margin-top: 18px;
}

.charts-card {
  margin-top: 18px;
}

.chart-block {
  margin-top: 12px;
}

.chart-block h3 {
  margin: 6px 0 10px;
  font-size: 15px;
  color: #c7d0f3;
}

.chart-block canvas {
  width: 100%;
  height: 280px;
  max-height: 280px;
}

.limits-bars {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: nowrap;
}

.limit-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(220px, calc((100% - 18px) / 2));
  min-width: 0;
}

.limit-title {
  margin-bottom: 8px;
  font-weight: 700;
  text-align: center;
  color: #d9e1ff;
}

.limit-title-with-action,
.chart-title-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.limit-settings-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
  border-radius: 999px;
}

.limit-analyze-btn {
  margin-top: 10px;
  width: 100%;
  max-width: 180px;
}

.radar-gauge {
  --progress: 0;
  --needle-angle: -135deg;
  --gauge-color: #3ec7c9;
  position: relative;
  width: min(170px, 100%);
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 50%;
  background: radial-gradient(circle at center, #ffffff 30%, #eef2f8 100%);
  box-shadow:
    inset 0 0 0 1px rgba(17, 24, 39, 0.08),
    0 8px 20px rgba(16, 24, 40, 0.14);
}

.radar-gauge::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 0 39%, rgba(16, 22, 37, 0.2) 39% 40%, transparent 40%),
    radial-gradient(circle at center, transparent 0 48%, rgba(16, 22, 37, 0.2) 48% 49%, transparent 49%),
    repeating-conic-gradient(
      from -135deg,
      rgba(16, 22, 37, 0.18) 0deg 1deg,
      transparent 1deg 18deg
    );
}

.radar-gauge-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from -135deg,
    var(--gauge-color) 0 calc(var(--progress) * 2.7deg),
    rgba(16, 22, 37, 0.1) calc(var(--progress) * 2.7deg) 270deg,
    transparent 270deg 360deg
  );
  mask: radial-gradient(circle at center, transparent 0 82%, #000 82% 87%, transparent 87%);
  -webkit-mask: radial-gradient(circle at center, transparent 0 82%, #000 82% 87%, transparent 87%);
  transition: background 0.35s ease;
}

.radar-gauge-needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 39%;
  background: linear-gradient(180deg, rgba(26, 255, 214, 0.95), rgba(62, 199, 201, 0.25));
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(var(--needle-angle));
  box-shadow: 0 0 10px rgba(62, 199, 201, 0.5);
  animation: needleJitter 1.15s steps(1, end) infinite;
}

#month-gauge .radar-gauge-needle {
  animation-duration: 1.08s;
}

#day-gauge .radar-gauge-needle {
  animation-duration: 1.23s;
  animation-delay: -0.18s;
}

.radar-gauge-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(10px, 9%, 16px);
  height: clamp(10px, 9%, 16px);
  border-radius: 50%;
  background: #3ec7c9;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 5px rgba(62, 199, 201, 0.2),
    0 0 10px rgba(62, 199, 201, 0.55);
}

.radar-gauge-value {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  color: #25324f;
  font-weight: 700;
  font-size: clamp(11px, 2.7vw, 14px);
}

@media (max-width: 520px) {
  .limits-bars {
    gap: 10px;
  }

  .limit-item {
    width: calc((100% - 10px) / 2);
  }
}

.gauge-over-limit {
  --gauge-color: #ef4444;
}

.gauge-over-limit .radar-gauge-center {
  background: #ef4444;
  box-shadow:
    0 0 0 5px rgba(239, 68, 68, 0.25),
    0 0 12px rgba(239, 68, 68, 0.6);
}

.gauge-over-limit .radar-gauge-needle {
  background: linear-gradient(180deg, rgba(255, 122, 122, 0.95), rgba(239, 68, 68, 0.25));
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.limit-caption {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.limit-caption-over-limit {
  color: #ff8793;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(255, 84, 118, 0.25);
}

form {
  display: grid;
  gap: 10px;
}

input,
select,
button {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
}

input,
select {
  border: 1px solid rgba(120, 143, 199, 0.45);
  background: rgba(8, 14, 30, 0.78);
  color: var(--text-main);
}

input::placeholder {
  color: #7382ac;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(100, 231, 224, 0.85);
  box-shadow: 0 0 0 3px rgba(55, 214, 204, 0.2);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.price-eval-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: #66728e;
  font-size: 13px;
}

.price-eval-field input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.price-eval-expensive {
  color: #c92a2a;
  font-weight: 700;
}

.receipt-import-action {
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

button {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, rgba(60, 199, 193, 0.96), rgba(27, 135, 169, 0.95));
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(6, 64, 90, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow:
    0 12px 22px rgba(6, 64, 90, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.secondary {
  background: linear-gradient(180deg, rgba(76, 92, 132, 0.95), rgba(44, 55, 85, 0.95));
}

.status {
  min-height: 20px;
  margin-top: 14px;
  color: #73ebc8;
}

#status-message {
  min-height: 0;
  margin-top: 8px;
}

#status-message:empty {
  display: none;
}

.forecast-hint {
  margin: 8px 0 12px;
  color: var(--text-muted);
}

.forecast-refresh-btn {
  display: block;
  margin-top: 6px;
}

.forecast-view {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.group-table-card {
  display: grid;
  gap: 6px;
}

.group-time-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  padding-left: 2px;
}

.group-purchases-table {
  table-layout: fixed;
}

.group-purchases-table th:nth-child(1),
.group-purchases-table td:nth-child(1) {
  width: 46%;
}

.group-purchases-table th:nth-child(2),
.group-purchases-table td:nth-child(2) {
  width: 12%;
}

.group-purchases-table th:nth-child(3),
.group-purchases-table td:nth-child(3) {
  width: 14%;
}

.group-purchases-table th:nth-child(4),
.group-purchases-table td:nth-child(4) {
  width: 28%;
}

.group-purchases-table th:nth-child(even),
.group-purchases-table td:nth-child(even) {
  background: #f5f7fa;
}

.purchases-card .purchases-table th,
.purchases-card .purchases-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 900px) {
  .purchases-card .purchases-table th,
  .purchases-card .purchases-table td {
    padding: 8px 6px;
  }

  .purchases-card .purchases-table th {
    font-size: 12px;
  }

  .purchases-card .purchases-table td {
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .purchases-card .purchases-table th,
  .purchases-card .purchases-table td {
    padding: 7px 5px;
  }

  .purchases-card .purchases-table th {
    font-size: 11px;
  }

  .purchases-card .purchases-table td {
    font-size: 12px;
  }

  .purchases-card .purchases-table th:nth-child(1),
  .purchases-card .purchases-table td:nth-child(1) {
    width: 42%;
  }

  .purchases-card .purchases-table th:nth-child(2),
  .purchases-card .purchases-table td:nth-child(2) {
    width: 16%;
  }

  .purchases-card .purchases-table th:nth-child(3),
  .purchases-card .purchases-table td:nth-child(3) {
    width: 16%;
  }

  .purchases-card .purchases-table th:nth-child(4),
  .purchases-card .purchases-table td:nth-child(4) {
    width: 26%;
  }
}

.group-purchases-table th,
.group-purchases-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 900px) {
  .group-purchases-table th,
  .group-purchases-table td {
    padding: 8px 6px;
  }

  .group-purchases-table th {
    font-size: 12px;
  }

  .group-purchases-table td {
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .group-purchases-table th,
  .group-purchases-table td {
    padding: 7px 5px;
  }

  .group-purchases-table th {
    font-size: 11px;
  }

  .group-purchases-table td {
    font-size: 12px;
  }

  .group-purchases-table th:nth-child(1),
  .group-purchases-table td:nth-child(1) {
    width: 42%;
  }

  .group-purchases-table th:nth-child(2),
  .group-purchases-table td:nth-child(2) {
    width: 16%;
  }

  .group-purchases-table th:nth-child(3),
  .group-purchases-table td:nth-child(3) {
    width: 14%;
  }

  .group-purchases-table th:nth-child(4),
  .group-purchases-table td:nth-child(4) {
    width: 28%;
  }
}

.profile-card {
  border: 1px solid rgba(108, 132, 193, 0.24);
  border-radius: 10px;
  background: rgba(12, 19, 38, 0.7);
  padding: 10px 12px;
}

.profile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.profile-card-title {
  font-size: 16px;
  font-weight: 700;
}

.profile-card-meta {
  margin: 4px 0 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.profile-pin-btn {
  border: 1px solid rgba(108, 132, 193, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: #b4c1e9;
  box-shadow: none;
  width: 32px;
  height: 32px;
  padding: 0;
  line-height: 1;
  font-size: 16px;
}

.profile-pin-btn:hover {
  box-shadow: none;
}

.profile-pin-btn-active {
  color: #dc2626;
  border-color: #fecaca;
  background: #fee2e2;
}

.forecast-summary {
  color: #d4ddfb;
  background: rgba(12, 19, 38, 0.7);
  border: 1px solid rgba(108, 132, 193, 0.24);
  border-radius: 10px;
  padding: 10px 12px;
}

.forecast-avoid-text {
  color: #ff7888;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.purchases-table {
  width: 100%;
  border-collapse: collapse;
}

.purchases-table th,
.purchases-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(110, 135, 188, 0.24);
  text-align: left;
  vertical-align: top;
}

.purchases-table th {
  color: #acb9e8;
  font-size: 13px;
  background: rgba(23, 33, 61, 0.82);
}

.purchases-table td {
  font-size: 14px;
  color: #e4eaff;
}

.purchases-card .purchases-table th:nth-child(even),
.purchases-card .purchases-table td:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

.empty-row {
  color: #8592bb;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.hidden {
  display: none;
}

.modal-content {
  width: min(780px, 92vw);
  max-height: 84vh;
  overflow: auto;
  background: rgba(14, 21, 40, 0.93);
  border: 1px solid rgba(112, 138, 201, 0.3);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  color: var(--text-main);
  box-shadow: 0 22px 46px rgba(2, 6, 16, 0.6);
  animation: slideIn 0.2s ease;
}

.widget-settings-content {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.task-settings-content {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-settings-content > input {
  width: 100%;
}

.plan-time-completion-content {
  width: min(420px, 92vw);
}

#plan-time-completion-text {
  margin: 8px 0 6px;
}

.plan-time-completion-timeout {
  margin: 0 0 12px;
  color: #5f6d86;
  font-size: 13px;
}

.widget-settings-content > label {
  display: block;
  margin-top: 2px;
  width: 100%;
}

.widget-settings-content > input,
.widget-settings-content > select {
  width: 100%;
}

.widget-settings-content > .hidden {
  display: none !important;
}

#widget-categories {
  min-height: 110px;
}

.widget-settings-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.close-btn {
  position: absolute;
  right: 14px;
  top: 10px;
  border: 0;
  background: transparent;
  color: #9ba8d1;
  font-size: 24px;
  cursor: pointer;
  box-shadow: none;
}

.close-btn:hover {
  transform: none;
  color: #dce6ff;
}

.analysis-summary {
  background: rgba(17, 27, 52, 0.76);
  border: 1px solid rgba(105, 129, 190, 0.28);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.analysis-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge-price-alert {
  font-size: 36px;
  line-height: 1.1;
  padding: 6px 16px;
}

.badge-good {
  background: rgba(35, 174, 120, 0.2);
  color: #79f0be;
}

.badge-warn {
  background: rgba(205, 57, 85, 0.2);
  color: #ff9aa8;
}

.badge-neutral {
  background: rgba(83, 118, 212, 0.25);
  color: #a8c1ff;
}

.analysis-section {
  margin-top: 14px;
}

.analysis-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #c8d4fd;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
}

.analysis-table th,
.analysis-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(110, 135, 188, 0.24);
  font-size: 13px;
  text-align: left;
}

.analysis-table th {
  background: rgba(23, 33, 61, 0.82);
  color: #acb9e8;
}

.analysis-table td {
  color: #dce4ff;
}

.receipt-import-modal-content h3 {
  margin-top: 0;
  text-align: center;
}

.receipt-import-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-bottom: 0;
  min-height: 0;
}

.receipt-import-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.receipt-import-illustration {
  display: block;
  max-height: 200px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

#receipt-import-pick-btn {
  width: 180px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.receipt-import-pick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#receipt-import-pick-camera-btn {
  width: 140px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

#receipt-import-total {
  margin-top: 10px;
  text-align: center;
}

#receipt-import-status {
  margin-top: 8px;
  min-height: 0;
  text-align: center;
}

#receipt-import-status:empty {
  display: none;
}

#receipt-import-expensive-warning {
  margin-top: 8px;
  margin-bottom: 0;
  text-align: center;
}

.receipt-import-expensive-warning {
  color: #c92a2a;
  font-weight: 700;
}

#receipt-import-preview {
  text-align: center;
}

.receipt-expensive-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  line-height: 1;
}

.receipt-pending-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  font-size: 12px;
  line-height: 1;
}

.receipt-ok-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid #16a34a;
  background: transparent;
  vertical-align: middle;
}

.receipt-expensive-price {
  color: #c92a2a !important;
  font-weight: 700;
}

.receipt-import-confirm-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

#receipt-import-cancel-btn {
  background: #dc2626;
}

.wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(2, 6, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.wait-overlay.hidden {
  display: none;
}

.wait-card {
  width: min(360px, 90vw);
  background: rgba(16, 24, 46, 0.92);
  border: 1px solid rgba(112, 138, 201, 0.3);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(2, 6, 16, 0.6);
  text-align: center;
}

.wait-icon {
  font-size: 34px;
  margin-bottom: 8px;
}

.wait-title {
  font-size: 18px;
  font-weight: 700;
  color: #dbe5ff;
}

.wait-subtitle {
  margin-top: 8px;
  color: #a3afd4;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes goldSheen {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes needleJitter {
  0% {
    transform: translate(-50.4%, -100.2%) rotate(calc(var(--needle-angle) - 1.8deg));
  }
  12% {
    transform: translate(-49.3%, -99.7%) rotate(calc(var(--needle-angle) + 1.15deg));
  }
  27% {
    transform: translate(-50.7%, -99.1%) rotate(calc(var(--needle-angle) - 0.95deg));
  }
  43% {
    transform: translate(-49.1%, -100.7%) rotate(calc(var(--needle-angle) + 1.7deg));
  }
  61% {
    transform: translate(-50.8%, -100.4%) rotate(calc(var(--needle-angle) - 1.35deg));
  }
  78% {
    transform: translate(-49.2%, -99.4%) rotate(calc(var(--needle-angle) + 0.9deg));
  }
  100% {
    transform: translate(-50%, -100%) rotate(var(--needle-angle));
  }
}

/* Light theme rollback (keep circular gauges) */
body {
  color: #263142;
  background: #e3e8ee;
  min-height: initial;
  position: static;
}

body::before {
  content: none;
}

.container {
  padding: 10px 16px 16px;
}

.plan-time-card {
  overflow: hidden;
}

.plan-time-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.plan-time-state-label {
  margin: 0;
  color: #42506b;
  font-weight: 700;
}

.plan-time-controls {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

#plan-time-status {
  margin-top: 8px;
  min-height: 0;
}

.plan-time-board {
  margin-top: 10px;
  padding: 16px;
  border-radius: 14px;
  background:
    linear-gradient(120deg, rgba(125, 86, 53, 0.3), rgba(146, 102, 61, 0.34)),
    repeating-linear-gradient(
      90deg,
      rgba(114, 74, 42, 0.38) 0 14px,
      rgba(140, 96, 61, 0.34) 14px 28px
    );
  border: 1px solid rgba(121, 84, 54, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.plan-photo {
  position: relative;
  background: #f8f8f8;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  padding: 14px 12px 10px;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.22),
    0 2px 0 rgba(255, 255, 255, 0.35) inset;
  min-height: 172px;
  display: flex;
  flex-direction: column;
}

.plan-photo:nth-child(odd) {
  transform: rotate(-1.5deg);
}

.plan-photo:nth-child(even) {
  transform: rotate(1.2deg);
}

.plan-photo-active {
  outline: 3px solid rgba(33, 160, 78, 0.75);
}

.plan-photo-active .plan-text {
  font-weight: 700;
  color: #0f2a1b;
}

.plan-photo-locked {
  opacity: 0.82;
}

.plan-zone-order {
  background: linear-gradient(180deg, #d8e6ff, #c2d8fc);
}

.plan-zone-planning {
  background: linear-gradient(180deg, #ffe3c2, #ffd3a3);
}

.plan-zone-action {
  background: linear-gradient(180deg, #d5f3cd, #bae9ad);
}

.plan-zone-finalization {
  background: linear-gradient(180deg, #ececec, #d8d8d8);
}

.plan-delete-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  font-size: 14px;
}

.plan-completion-badge {
  position: absolute;
  right: 42px;
  top: 8px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.plan-completion-success {
  color: #1f7a36;
}

.plan-completion-failed {
  color: #b91c1c;
}

.plan-order-badge {
  position: absolute;
  left: 10px;
  top: 8px;
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  color: rgba(0, 0, 0, 0.2);
}

.plan-text {
  margin-top: 34px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #202331;
  font-size: 14px;
  flex: 1;
  cursor: text;
}

.plan-text-placeholder {
  color: rgba(32, 35, 49, 0.45);
}

.plan-text-edit {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}

.plan-footer {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.plan-duration-input {
  width: 100%;
  text-align: center;
  font-weight: 700;
}

.plan-timer {
  text-align: center;
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
  color: #1f3f1f;
}

.plan-time-alert {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  font-size: min(40vw, 320px);
  font-weight: 900;
  color: rgba(220, 38, 38, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.plan-time-alert-visible {
  opacity: 1;
  animation: planBlink 1.2s ease;
}

.plan-order-modal-content {
  width: min(520px, 92vw);
}

.plan-order-modal-content h3 {
  margin: 2px 0 10px;
}

.plan-order-hint {
  margin: 0 0 10px;
  color: #5b677f;
}

.plan-order-counter {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.plan-order-counter button {
  width: 100%;
  height: 52px;
  padding: 0;
  border-radius: 12px;
  font-size: 28px;
  line-height: 1;
}

.plan-order-value {
  height: 52px;
  border-radius: 12px;
  background: #e9eef4;
  border: 1px solid #cfd8e3;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  color: #2e3a4d;
}

.plan-order-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e8eef6;
  border: 1px solid #cfd8e3;
  overflow-x: auto;
  margin-bottom: 12px;
}

.plan-order-dot {
  border: 0;
  background: transparent;
  color: #6a7486;
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 700;
  min-width: 38px;
}

.plan-order-dot-active {
  background: #2c7ec2;
  color: #fff;
}

.plan-order-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

@keyframes planBlink {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  25% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.03);
  }
}

@media (max-width: 980px) {
  .plan-time-board {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  .plan-time-board {
    grid-template-columns: 1fr;
  }
}

.gold-title {
  font-size: 1.1em;
  font-weight: 700;
  color: #2e2200;
  background: linear-gradient(
    110deg,
    #7a5a00 0%,
    #b8890a 22%,
    #ffe59f 46%,
    #bf910e 66%,
    #765600 100%
  );
  background-size: 220% auto;
  background-clip: initial;
  -webkit-background-clip: initial;
  -webkit-text-fill-color: initial;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 216, 0.55),
    inset 0 -1px 0 rgba(84, 59, 0, 0.22);
  text-shadow:
    0 1px 0 rgba(255, 247, 201, 0.9),
    0 -1px 0 rgba(119, 84, 5, 0.5),
    1px 0 0 rgba(123, 88, 6, 0.35),
    -1px 0 0 rgba(255, 233, 161, 0.35),
    0 2px 2px rgba(64, 44, 0, 0.22);
  animation: goldSheen 5s ease-in-out infinite;
}

.tab-btn {
  border: 1px solid #5f6c7a;
  border-bottom: 0;
  background: #6a7480;
  color: #ecf2f8;
  border-radius: 12px 12px 0 0;
  margin-bottom: -1px;
  box-shadow: none;
}

.tab-btn-active {
  background: #1db8b1;
  color: #fff;
  border-color: #1db8b1;
}

.card {
  background: #fff;
  border: 1px solid #d4dbe4;
  box-shadow: 0 6px 18px rgba(32, 46, 66, 0.08);
  backdrop-filter: none;
}

.section-title-icon {
  filter: none;
}

.chart-block h3 {
  color: inherit;
}

.limit-title {
  color: inherit;
}

.limit-caption {
  display: none;
  color: #4f5a71;
}

.limit-caption-over-limit {
  color: #b42318;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

input,
select {
  border: 1px solid #c7d0db;
  background: #f8fafc;
  color: #263142;
}

input::placeholder {
  color: #8793a6;
}

input:focus,
select:focus {
  outline: none;
  border-color: #27b5ae;
  box-shadow: none;
}

button {
  background: #1fbcb4;
  color: #ffffff;
  box-shadow: none;
  transition: opacity 0.2s ease;
}

button:hover {
  opacity: 0.9;
  transform: none;
  box-shadow: none;
}

.secondary {
  background: #6b7480;
}

.price-eval-field {
  color: #556079;
}

.status {
  color: #2b8a3e;
}

.forecast-hint {
  color: #4f5a71;
}

.group-time-label {
  color: #4f5a71;
}

.forecast-summary {
  color: #2c3446;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.profile-card {
  border-color: #e7ebf3;
  background: #fff;
}

.profile-card-meta {
  color: #556079;
}

.profile-pin-btn {
  border-color: #d0d8ea;
  background: #f8f9fc;
  color: #6b7280;
}

.profile-pin-btn.profile-pin-btn-active {
  color: #dc2626;
  border-color: #fecaca;
  background: #fee2e2;
}

.profile-card .analysis-table th,
.profile-card .analysis-table td {
  border-bottom: 1px solid #d9deea;
}

.profile-card .analysis-table th {
  color: #dfe7ff;
}

.profile-card .analysis-table td {
  color: #1f2937;
  background: #ffffff;
}

.forecast-avoid-text {
  color: #d94848;
}

.purchases-table th,
.purchases-table td {
  border-bottom: 1px solid #e7ebf3;
}

.purchases-table th {
  color: #4a566b;
  background: #eef2f6;
}

.purchases-table td {
  color: #202331;
}

.purchases-card .purchases-table th:nth-child(even),
.purchases-card .purchases-table td:nth-child(even) {
  background: #f5f7fa;
}

.group-purchases-table th:nth-child(even),
.group-purchases-table td:nth-child(even) {
  background: #f5f7fa;
}

.empty-row {
  color: #7b8498;
}

.modal {
  background:
    radial-gradient(circle at 20% 15%, rgba(41, 181, 174, 0.12) 0%, transparent 28%),
    radial-gradient(circle at 82% 24%, rgba(95, 107, 123, 0.15) 0%, transparent 30%),
    rgba(35, 45, 60, 0.56);
  z-index: 1400;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: #ffffff;
  border: 1px solid #d2dae5;
  color: #253044;
  box-shadow: 0 16px 34px rgba(24, 35, 51, 0.2);
  border-radius: 18px;
}

.close-btn {
  color: #6a7588;
}

.close-btn:hover {
  color: #2b364b;
}

.analysis-summary {
  background: #f4f7fb;
  border: 1px solid #d8e0ea;
  box-shadow: none;
}

.badge-good {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge-warn {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.26), rgba(220, 38, 38, 0.2));
  color: #fecdd3;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.badge-neutral {
  background: #e4efff;
  color: #2f588f;
}

.analysis-section h3 {
  color: #2d3a4f;
}

.analysis-table th,
.analysis-table td {
  border-bottom: 1px solid #d8e0ea;
}

.analysis-table th {
  background: #edf2f7;
  color: #4b586c;
}

.analysis-table td {
  color: #263142;
}

.wait-card {
  background: #fff;
  border: none;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.2);
}

.wait-title {
  color: #202331;
}

.wait-subtitle {
  color: #4f5a71;
}
