/* Remnawave-inspired: deep space, violet/cyan accents, glass panels */

:root {
  --bg-0: #07070c;
  --bg-1: #0c0c14;
  --bg-2: #12121c;
  --surface: rgba(22, 22, 34, 0.72);
  --surface-border: rgba(139, 92, 246, 0.18);
  --text: #e8e6f0;
  --muted: #8b8699;
  --accent: #a78bfa;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --radius: 14px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: dark;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg-0);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(139, 92, 246, 0.22), transparent),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(34, 211, 238, 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(167, 139, 250, 0.08), transparent);
  background-attachment: scroll;
  overflow-x: hidden;
}

a {
  color: var(--accent-2);
  text-underline-offset: 0.15em;
}

a:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(2rem + var(--safe-t)) max(1.25rem, var(--safe-l)) max(3rem, calc(1.5rem + var(--safe-b))) max(1.25rem, var(--safe-r));
}

header.brand {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(167, 139, 250, 0.15);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.06);
}

.icon-btn svg {
  display: block;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.28rem, 4.2vw, 1.65rem);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .brand h1 {
    color: var(--text);
    background: none;
  }
}

.brand p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panels {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .panels {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }

  .panels.panels-single {
    grid-template-columns: 1fr;
  }
}

.panels-single {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.week-picker {
  margin-bottom: 1.25rem;
  padding: 1rem 1.4rem;
}

.week-picker label {
  margin-bottom: 0.5rem;
}

.week-picker-row select {
  margin-bottom: 0;
}

.week-subtitle {
  margin: -0.35rem 0 1rem;
  font-size: 0.95rem;
  color: var(--accent-2);
  font-weight: 500;
}

.week-picker-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.week-picker-inline input[type="date"] {
  margin-bottom: 0;
  max-width: 12rem;
}

.manage-wrap {
  max-width: 1100px;
}

.manage-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 800px) {
  .manage-layout {
    grid-template-columns: 200px 1fr;
    align-items: start;
  }
}

.manage-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem !important;
}

.manage-nav-link {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.manage-nav-link:hover {
  color: var(--text);
  background: rgba(167, 139, 250, 0.08);
}

.manage-nav-link.is-active {
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.08);
  border-color: rgba(34, 211, 238, 0.2);
}

.manage-content {
  min-width: 0;
}

.manage-week-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toolbar-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.expense-add-block {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--surface-border);
  scroll-margin-top: 1rem;
}

.expense-add-block h3.form-section-title {
  margin-bottom: 0.35rem;
}

.btn-header {
  padding: 0.5rem 1rem !important;
  font-size: 0.9rem !important;
  text-decoration: none;
  white-space: nowrap;
}

.card {
  background: rgba(22, 22, 34, 0.94);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem;
}

@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
  .card {
    background: var(--surface);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.25);
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
  -webkit-tap-highlight-color: transparent;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  min-height: 2.75rem;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(167, 139, 250, 0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 36px rgba(99, 102, 241, 0.45);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.35);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.85rem 1rem;
  background: rgba(10, 10, 18, 0.85);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--surface-border);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
  vertical-align: middle;
}

tbody tr:hover td {
  background: rgba(167, 139, 250, 0.04);
}

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

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.flash-ok {
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: #67e8f9;
}

.flash-err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.hours-cell {
  font-weight: 600;
  color: var(--accent-2);
}

.summary {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--surface-border);
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  font-size: 0.95rem;
}

.summary-line .lbl {
  color: var(--muted);
}

.summary-line .val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
  text-align: right;
}

.summary-line.extra .lbl {
  color: var(--text);
}

.summary-total {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(167, 139, 250, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 1.05rem;
}

.summary-total .lbl {
  color: var(--accent);
  font-weight: 600;
}

.summary-total .val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.extras-form {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 10px;
  background: rgba(10, 10, 18, 0.5);
  border: 1px solid rgba(139, 92, 246, 0.12);
}

.extras-form h3 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.extras-form .row2 {
  margin-bottom: 0;
}

.extras-form .btn-primary {
  margin-top: 0.5rem;
  width: 100%;
}

.extra-del {
  margin-left: 0.5rem;
}

.settings-panels {
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .settings-panels {
    grid-template-columns: 1fr 1fr;
  }
}

.settings-hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.preset-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.12);
  overflow: hidden;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
  font-size: 0.95rem;
}

.preset-item-text {
  flex: 1;
  min-width: 0;
}

.preset-item:last-child {
  border-bottom: none;
}

.preset-add-form {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface-border);
}

.form-section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ——— Адаптивность и мобильные браузеры ——— */

@media (max-width: 640px) {
  header.brand {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .brand-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .brand-actions .btn-header {
    flex: 1 1 auto;
    min-width: min(100%, 12rem);
    justify-content: center;
  }

  .card {
    padding: 1.1rem 1.15rem;
  }

  .week-picker {
    padding: 1rem 1.1rem;
  }
}

@media (max-width: 520px) {
  .row2 {
    grid-template-columns: 1fr;
  }

  .week-picker-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .week-picker-inline input[type="date"] {
    max-width: none;
    width: 100%;
  }

  .week-picker-inline .btn {
    width: 100%;
  }

  .manage-week-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-btns {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-btns .btn,
  .toolbar-btns .btn-header {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 799px) {
  .manage-nav {
    flex-direction: row !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 0.45rem !important;
    padding: 0.7rem 0.85rem !important;
    scrollbar-width: thin;
  }

  .manage-nav-link {
    flex: 0 0 auto;
    padding: 0.55rem 0.8rem;
  }
}

@media (max-width: 480px) {
  input,
  select {
    font-size: 1rem;
  }

  html {
    font-size: 16px;
  }

  .summary-line,
  .summary-total {
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
  }

  .preset-item {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .preset-item form {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
  }

  .preset-item .btn-danger {
    width: 100%;
    min-height: 2.75rem;
  }
}

@media (pointer: coarse) {
  .btn-danger {
    min-height: 2.5rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .actions .btn-danger {
    min-height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .icon-btn {
    transition: none;
  }

  .btn:active {
    transform: none;
  }

  .btn-primary:hover {
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.35);
  }
}

img {
  max-width: 100%;
  height: auto;
}
