:root {
  --accent: #f59e0b;
  --accent-light: #fff7e6;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #f0fdf4;
  --danger: #dc2626;
  --text: #17211b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #ffffff;
  --background: #f5f7f6;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(
      circle at 0 0,
      rgba(245, 158, 11, 0.08),
      transparent 30%
    ),
    var(--background);
  color: var(--text);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.02em;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.25);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  max-width: 2500px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
}

.sidebar,
.workspace {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 19px;
  display: flex;
  flex-direction: column;
  background-image: url(../images/grid.png);
  background-repeat: no-repeat;
}

.brand {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  color: var(--accent);
  font-size: 42px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.07em;
}

.brand-subtitle {
  max-width: 240px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  color: black;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 26px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select,
.large-input input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: 0.2s;
}

select:hover,
select:focus,
.large-input input:focus {
  border-color: var(--primary);
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.month-button {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: 0.2s;
}

.month-button:hover {
  border-color: var(--primary);
}

.month-button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 5px 15px rgba(245, 158, 11, 0.25);
}

.month-button.disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.segmented-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--primary-light);
  border: 1px solid #dcfce7;
  border-radius: 13px;
}

.segmented-control button {
  flex: 1;
  min-width: 0;
  padding: 9px 5px;
  color: var(--muted);
  background: transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: 0.2s;
}

.segmented-control button.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.2);
}

.field-hint {
  color: #86a58e;
  font-size: 10px;
}

.power-options {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.power-options button {
  padding: 10px 12px;
  color: var(--muted);
  background: var(--primary-light);
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  transition: 0.2s;
}

.power-options button.active {
  color: #fff;
  background: var(--primary);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 28px;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--primary);
  background: #fff;
  border: 1px solid #bbf7d0;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    background 0.2s,
    color 0.2s;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(16, 24, 40, 0.08);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.button-outline-accent {
  color: var(--accent);
  border-color: var(--accent);
}

.button-outline {
  color: var(--primary);
}

.button-danger {
  color: var(--danger);
  background: #fff;
  border-color: #fecaca;
}

.button-calculate {
  min-height: 48px;
  padding: 0 24px;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  font-size: 16px;
  position: relative;
  overflow: hidden;
  animation: autoShine 5s ease-in-out;
}

@keyframes autoShine {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

.button-calculate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: 0.5s;
}

.button-calculate:hover::before {
  left: 100%;
}

/* Auto-shine animation for every page load */
@keyframes autoShine {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

/* Apply animation on page load */
.button-calculate {
  animation: autoShine 1.5s ease-in-out;
}

.button-calculate.shine {
  animation: shine 1.5s ease-in-out;
}

@keyframes shine {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

.workspace {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-header h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--primary);
}

.period-badge {
  padding: 10px 15px;
  color: #333;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
}

.profile-card {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: #fbfdfc;
  border: 1px solid var(--border);
  border-radius: 20px;
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.profile-header h2 {
  font-size: 17px;
}

.profile-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.volume-display {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 14px;
  background: #ff;
  border: 1px solid #fde68a;
  border-radius: 12px;
  white-space: nowrap;
}

.volume-display span {
  color: #b45309;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.volume-display strong {
  color: #92400e;
  font-size: 18px;
}

.volume-display small {
  color: #b45309;
  font-size: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-container {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.consumption-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10px;
}

.consumption-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 3px;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-bottom: 1px solid #bbf7d0;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.consumption-table th:first-child {
  left: 0;
  z-index: 3;
}

.consumption-table td {
  padding: 2px;
  border-bottom: 1px solid #f0f2f1;
}

.day-column,
.day-cell {
  position: sticky;
  left: 0;
  width: 50px;
  min-width: 50px;
  text-align: center;
}

.day-cell {
  color: var(--primary-dark);
  background: #fff;
  font-weight: 800;
}

.hour-input {
  width: 100%;
  min-width: 38px;
  height: 30px;
  padding: 0 2px;
  color: var(--text);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  outline: none;
  font-size: 10px;
  text-align: center;
  transition: 0.15s;
}

.hour-input:focus {
  border-color: var(--primary);
  background: var(--primary-light);
}

.table-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(1px);
  overflow-y: auto;
}

.modal {
  position: relative;
  width: min(500px, 100%);
  max-height: calc(100vh - 40px);
  padding: 30px;
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

.modal-wide {
  width: min(900px, 100%);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: #f8fafc;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: #f1f5f9;
}

.modal-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  border-radius: 14px;
  font-size: 21px;
  font-weight: 800;
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.modal p {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal textarea {
  width: 100%;
  min-height: 250px;
  padding: 14px;
  resize: vertical;
  color: var(--text);
  background: #fbfdfc;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-size: 12px;
}

.modal textarea:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.large-input {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.large-input input {
  min-height: 58px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.large-input span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.distribution-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.distribution-options button {
  padding: 14px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: 0.2s;
}

.distribution-options button.active {
  color: var(--primary-dark);
  background: var(--primary-light);
  border-color: var(--primary);
}

.distribution-options strong,
.distribution-options span {
  display: block;
}

.distribution-options strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.distribution-options span {
  font-size: 10px;
}

.result-modal {
  width: min(1000px, 100%);
}

.result-modal-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-right: 35px;
}

.result-modal-header .modal-icon {
  flex-shrink: 0;
  margin: 0;
}

.result-modal-header h2 {
  margin-bottom: 4px;
}

.result-modal-header p {
  margin: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}

.result-card {
  padding: 18px;
  background: linear-gradient(
    145deg,
    #ffffff,
    #f8faf9
  );
  border: 1px solid var(--border);
  border-radius: 16px;
}

.result-card-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-cost {
  margin: 12px 0 18px;
  color: var(--primary-dark);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.05em;
  font-family: Consolas;
}

.result-cost small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
}

.result-stats strong {
  font-size: 13px;
  word-break: break-all;
}

.result-details {
  margin-top: 20px;
}

.details-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid #dcfce7;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.details-toggle span:last-child {
  transition: 0.2s;
}

.details-toggle .rotated {
  transform: rotate(180deg);
}

.details-content {
  margin-top: 12px;
  padding: 16px;
  background: #fbfdfc;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.details-content h3 {
  margin-bottom: 12px;
  font-size: 14px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.results-table th {
  padding: 10px 8px;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-bottom: 1px solid #bbf7d0;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.results-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.results-table td:first-child {
  font-weight: 700;
  text-align: left;
}

.results-table tr:last-child td {
  border-bottom: 0;
}

.total-row td {
  color: var(--primary-dark);
  background: var(--primary-light);
  font-weight: 800;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  padding: 16px;
  background: var(--primary-light);
  border: 1px solid #dcfce7;
  border-radius: 14px;
}

.faq-item h3 {
  margin-bottom: 7px;
  color: var(--primary-dark);
  font-size: 13px;
}

.faq-item p {
  margin: 0;
  font-size: 12px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #dcfce7;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.modal-enter-active,
.modal-leave-active {
  transition: opacity 0.2s ease;
}

.modal-enter-active .modal,
.modal-leave-active .modal {
  transition: transform 0.2s ease;
}

.modal-enter-from,
.modal-leave-to {
  opacity: 0;
}

.modal-enter-from .modal,
.modal-leave-to .modal {
  transform: translateY(15px) scale(0.98);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sidebar {
    padding: 20px;
  }

  .workspace {
    padding: 20px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-calculate {
    width: 100%;
  }
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  .app-shell {
    min-height: calc(100vh - 24px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-radius: 20px;
  }

  .sidebar-actions {
    margin-top: 24px;
  }

  .workspace {
    border-radius: 20px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-badge {
    width: 100%;
    text-align: center;
  }

  .profile-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .volume-display {
    width: 100%;
    justify-content: center;
  }

  .toolbar-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-group .button {
    width: 100%;
    padding: 0 8px;
    white-space: normal;
  }

  .modal {
    padding: 22px;
    border-radius: 20px;
  }

  .result-modal-header {
    align-items: flex-start;
  }

  .distribution-options {
    grid-template-columns: 1fr;
  }

  .results-table {
    min-width: 600px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }
}

/* Diamond shine animation for calculate button */
.button-calculate {
  position: relative;
  overflow: hidden;
}

.button-calculate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: 0.5s;
}

.button-calculate:hover::before {
  left: 100%;
}

.button-calculate.shine {
  animation: shine 1.5s ease-in-out;
}

@keyframes shine {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}