:root {
  --ink: #050706;
  --muted: #687064;
  --paper: #f4f6f1;
  --panel: #ffffff;
  --line: #dce3d5;
  --accent: #b7ff00;
  --accent-dark: #4f7100;
  --green: #79b700;
  --red: #c24135;
  --dark-panel: #0b0f0a;
  --shadow: 0 22px 70px rgba(5, 7, 6, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(183, 255, 0, 0.14), transparent 30%),
    linear-gradient(180deg, #11170e 0, #11170e 180px, var(--paper) 181px),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden,
.admin-only.is-hidden {
  display: none !important;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 8%, rgba(183, 255, 0, 0.2), transparent 34%),
    linear-gradient(180deg, #050706, #11170e 58%, #f4f6f1 58%);
}

.auth-panel,
.entry-panel,
.side-panel,
.filter-panel,
.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-panel {
  position: relative;
  overflow: hidden;
  width: min(440px, 100%);
  padding: 26px;
  border-color: rgba(183, 255, 0, 0.34);
}

.auth-panel::before {
  position: absolute;
  inset: 0 auto auto 0;
  width: 92px;
  height: 100%;
  background: linear-gradient(145deg, rgba(118, 183, 42, 0.2), rgba(183, 255, 0, 0));
  clip-path: polygon(0 0, 100% 0, 34% 100%, 0 100%);
  content: "";
  pointer-events: none;
}

.auth-panel > * {
  position: relative;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup.compact {
  min-width: 0;
}

.brand-logo {
  width: 104px;
  height: auto;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 12px 32px rgba(5, 7, 6, 0.16);
}

.compact-logo {
  width: 58px;
}

.brand-lockup p,
.section-title p {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup h1,
.section-title h2 {
  margin: 0;
  line-height: 1.08;
}

.brand-lockup h1 {
  font-size: clamp(1.08rem, 2vw, 1.48rem);
}

.auth-form,
#valueForm {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #20261e;
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid #cfd8c8;
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfdf8;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 255, 0, 0.25);
}

.primary-btn,
.secondary-btn,
.chip-btn,
.icon-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary-btn {
  color: #071006;
  background: var(--ink);
  background: var(--accent);
  box-shadow: 0 12px 26px rgba(100, 150, 0, 0.22);
}

.secondary-btn {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #f9fff0;
}

.chip-btn {
  border: 1px solid var(--line);
  padding: 0 16px;
  color: var(--ink);
  background: white;
}

.chip-btn.is-active,
.tab.is-active {
  color: #071006;
  border-color: var(--accent);
  background: var(--accent);
}

.icon-btn {
  display: grid;
  width: 44px;
  place-items: center;
  border: 1px solid rgba(183, 255, 0, 0.45);
  color: var(--accent);
  background: #11170e;
}

.feedback {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.feedback.error {
  color: var(--red);
}

.feedback.ok {
  color: var(--accent-dark);
}

.demo-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px dashed rgba(183, 255, 0, 0.65);
  border-radius: 8px;
  background: #f4ffe0;
}

.demo-box p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.demo-actions,
.period-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(183, 255, 0, 0.22);
  border-radius: 8px;
  color: white;
  background: rgba(5, 7, 6, 0.96);
  box-shadow: 0 18px 42px rgba(5, 7, 6, 0.2);
}

.topbar::after {
  position: absolute;
  inset: 0 0 0 auto;
  width: 170px;
  background: linear-gradient(135deg, transparent 0 34%, rgba(183, 255, 0, 0.18) 35% 65%, rgba(118, 183, 42, 0.35) 66%);
  content: "";
  pointer-events: none;
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-area span {
  max-width: 240px;
  overflow: hidden;
  color: #dce6d6;
  font-size: 0.9rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-badge {
  max-width: none;
  border: 1px solid rgba(183, 255, 0, 0.5);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--accent);
  background: rgba(183, 255, 0, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 18px;
}

.tab {
  min-height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #e8eee4;
  background: rgba(5, 7, 6, 0.78);
  font-weight: 850;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 16px;
  min-width: 0;
}

.entry-panel,
.side-panel,
.filter-panel,
.table-section {
  min-width: 0;
  padding: 18px;
}

.entry-panel {
  position: relative;
  overflow: hidden;
  border-top: 4px solid var(--accent);
}

.entry-panel::after {
  position: absolute;
  inset: auto 0 0 auto;
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, transparent 0 45%, rgba(183, 255, 0, 0.16) 46%);
  content: "";
  pointer-events: none;
}

.entry-panel.narrow {
  max-width: 760px;
}

.section-title {
  margin-bottom: 16px;
}

.section-title.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.admin-filters {
  grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr)) auto auto;
  align-items: end;
}

.custom-period {
  display: none;
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.custom-period.is-visible {
  display: grid;
}

.calculation-strip,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.calculation-strip {
  margin: 16px 0;
}

.calculation-strip div,
.summary-grid article,
.metric-stack article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdf8;
}

.calculation-strip span,
.summary-grid span,
.metric-stack span,
.daily-row span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.calculation-strip strong,
.summary-grid strong,
.metric-stack strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 4vw, 2rem);
  color: var(--green);
}

#valuePreview {
  color: #5f9100;
  font-size: clamp(1.65rem, 7vw, 2.45rem);
}

.save-btn {
  width: 100%;
  margin-top: 14px;
  min-height: 54px;
  font-size: 1rem;
  text-transform: uppercase;
}

.metric-stack {
  display: grid;
  gap: 10px;
}

.responsive-table {
  width: 100%;
  overflow-x: auto;
}

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

.wide-table {
  min-width: 980px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #52604d;
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

.row-action {
  min-height: 34px;
  border: 1px solid #e6c1ba;
  border-radius: 8px;
  color: var(--red);
  background: #fff8f6;
  font-weight: 850;
}

.action-cell {
  min-width: 136px;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mini-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  color: var(--ink);
  background: #f9fff0;
  font-size: 0.78rem;
  font-weight: 900;
}

.danger-btn {
  border-color: #efb5ad;
  color: #9f2f25;
  background: #fff4f2;
}

.filter-panel {
  box-shadow: none;
}

.summary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.value-active-grid {
  margin-bottom: 0;
}

.daily-list {
  display: grid;
  gap: 10px;
}

.admin-breakdowns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.daily-row {
  display: grid;
  grid-template-columns: 1fr repeat(3, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdf8;
}

.daily-row strong {
  white-space: nowrap;
}

.admin-row {
  grid-template-columns: 1fr repeat(5, auto);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 7, 6, 0.76);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid rgba(183, 255, 0, 0.28);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.42);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(183, 255, 0, 0.38);
  border-radius: 8px;
  padding: 12px 14px;
  color: #071006;
  background: var(--accent);
  box-shadow: 0 18px 54px rgba(5, 7, 6, 0.25);
  font-weight: 900;
}

.toast.error {
  border-color: #efb5ad;
  color: white;
  background: var(--red);
}

@media (max-width: 900px) {
  .split-layout,
  .form-grid,
  .custom-period,
  .admin-filters,
  .summary-grid,
  .admin-breakdowns {
    grid-template-columns: 1fr;
  }

  .custom-period.is-visible {
    display: grid;
  }

  .calculation-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-logo {
    width: 88px;
  }

  .compact-logo {
    width: 52px;
  }

  .brand-lockup h1 {
    font-size: 1rem;
  }

  .user-area {
    flex-direction: column;
    align-items: flex-end;
  }

  .entry-panel,
  .side-panel,
  .filter-panel,
  .table-section {
    padding: 14px;
  }

  .calculation-strip {
    grid-template-columns: 1fr;
  }

  .daily-row {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

  .table-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
