/* Оболочка «Напоминания об оплатах»: сначала телефон, тёмная тема — по настройке устройства. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15181d;
  --muted: #5d6673;
  --border: #dde1e6;
  --accent: #15803d;
  --accent-text: #ffffff;
  --link: #166534;

  /* Цвета сроков — всегда вместе с подписью словами */
  --red: #c81e1e;
  --red-bg: #fde8e8;
  --yellow: #8a5a00;
  --yellow-bg: #fdf3d7;
  --green: #15803d;
  --green-bg: #e3f5e9;
  --none: #5d6673;
  --none-bg: #eef0f3;

  --radius: 14px;
  --gap: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #e9ecf1;
    --muted: #9aa3b0;
    --border: #2c313a;
    --accent: #22a55a;
    --accent-text: #06120a;
    --link: #6fd39a;

    --red: #ff7b7b;
    --red-bg: #3a1a1c;
    --yellow: #f2c45a;
    --yellow-bg: #362b12;
    --green: #5fd68c;
    --green-bg: #15301f;
    --none: #9aa3b0;
    --none-bg: #22262e;

    --shadow: none;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--link); }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* --- шапка --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.topnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }

/* --- экран --- */
.screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  outline: none;
}
.screen h1 { font-size: 24px; margin: 4px 0 16px; }
.screen h2 { font-size: 18px; margin: 24px 0 8px; }

.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }

/* --- карточка --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

/* --- кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* --- поля формы --- */
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: 15px; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field textarea { min-height: 88px; resize: vertical; }
.field .hint { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.field-error { color: var(--red); font-size: 14px; margin-top: 4px; }

/* --- статусы сроков (цвет + слова) --- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.status-red    { color: var(--red);    background: var(--red-bg); }
.status-yellow { color: var(--yellow); background: var(--yellow-bg); }
.status-green  { color: var(--green);  background: var(--green-bg); }
.status-none, .status-done { color: var(--none); background: var(--none-bg); }
.card.edge-red    { border-left: 5px solid var(--red); }
.card.edge-yellow { border-left: 5px solid var(--yellow); }
.card.edge-green  { border-left: 5px solid var(--green); }
.card.edge-none, .card.edge-done { border-left: 5px solid var(--border); }

/* --- заглушка экрана --- */
.placeholder { padding: 32px 16px; text-align: center; }
.placeholder h1 { margin-bottom: 8px; }

/* --- нет связи --- */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px 16px;
  background: var(--yellow-bg);
  color: var(--yellow);
  font-weight: 600;
  text-align: center;
}
body.offline [data-needs-online] { opacity: .5; pointer-events: none; }

/* --- всплывающие сообщения --- */
.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  pointer-events: auto;
}
.toast.toast-error { background: var(--red); color: #fff; }
.toast span { flex: 1; }
.toast button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  min-height: 36px;
}

@media (min-width: 720px) {
  .screen { padding: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .18s ease-out; }
  @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
}
