/* ============================================================
   Entre Portal — Styles
   Тёмная тема, amber-акценты, mobile-first (375px base)
   ============================================================ */

/* ── Reset & tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080810;
  --bg2:       #0f0f1a;
  --bg3:       #16162a;
  --border:    #2a2a45;
  --amber:     #F5A623;
  --amber-dim: #c07d0f;
  --text:      #e8e8f0;
  --text-dim:  #888899;
  --green:     #22c55e;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --r:         14px;   /* border-radius стандартный */
  --r-sm:      8px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Safe-area для iPhone с чёлкой ── */
body { padding-bottom: env(safe-area-inset-bottom); }

/* ============================================================
   Экраны и лейаут
   ============================================================ */

#app { display: flex; flex-direction: column; min-height: 100vh; }

.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* Скроллируемая область */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

/* ── Топбар ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 52px;
}
.topbar-title  { font-size: 18px; font-weight: 700; color: var(--amber); }
.topbar-back   {
  background: none; border: none; color: var(--text-dim);
  font-size: 24px; line-height: 1; cursor: pointer;
  padding: 4px 8px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center;
}
.topbar-action {
  background: none; border: none; color: var(--amber);
  font-size: 15px; font-weight: 600; cursor: pointer;
  padding: 4px 8px; min-height: 44px; display: flex; align-items: center;
}

/* ── Bottom-навигация ── */
.bottom-nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-btn {
  flex: 1; background: none; border: none;
  color: var(--text-dim);
  padding: 10px 4px 12px;
  cursor: pointer; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .15s;
  min-height: 56px;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn.active    { color: var(--amber); }

/* ============================================================
   Карточки
   ============================================================ */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 14px;
}

/* ============================================================
   Кнопки
   ============================================================ */

.btn {
  display: block; width: 100%; min-height: 52px;
  border: none; border-radius: var(--r); cursor: pointer;
  font-size: 17px; font-weight: 700; font-family: var(--font);
  padding: 12px 16px; text-align: center;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active            { transform: scale(.97); opacity: .88; }
.btn:disabled          { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--amber);  color: #000; }
.btn-secondary{ background: var(--bg3);    color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: var(--red);    color: #fff; }
.btn-success  { background: var(--green);  color: #fff; }

/* Компактная версия */
.btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; min-height: 38px;
  font-size: 14px; padding: 6px 16px;
  border-radius: var(--r-sm);
}

/* ============================================================
   Плитки (Home)
   ============================================================ */

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.tile {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px 12px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; min-height: 110px; justify-content: center;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tile:active { background: var(--bg3); border-color: var(--amber); }

.tile.tile-main {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #1a1a0a 0%, #241e00 100%);
  border-color: var(--amber);
  min-height: 88px;
  flex-direction: row; gap: 12px; justify-content: center;
  padding: 20px 24px;
}
.tile-icon  { font-size: 30px; line-height: 1; }
.tile-label { font-size: 14px; font-weight: 600; color: var(--text); text-align: center; line-height: 1.3; }
.tile.tile-main .tile-icon  { font-size: 28px; }
.tile.tile-main .tile-label { font-size: 18px; color: var(--amber); }

/* ============================================================
   Формы
   ============================================================ */

.form-group  { margin-bottom: 18px; }

.form-label {
  display: block; margin-bottom: 7px;
  font-size: 12px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 14px;
  font-size: 16px; /* минимум 16px — iOS не зумит */
  font-family: var(--font);
  appearance: none; -webkit-appearance: none;
  transition: border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus  { outline: none; border-color: var(--amber); }

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-dim); opacity: .6; }

/* Стрелка для select */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888899' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.form-textarea { resize: vertical; min-height: 88px; line-height: 1.5; }

/* ── Цвет для input[type=date/time/month] ── */
input[type="date"],
input[type="time"],
input[type="month"] { color-scheme: dark; }

/* ============================================================
   Прогресс-бар и точки недели
   ============================================================ */

.progress-wrap {
  background: var(--bg3); border-radius: 99px;
  height: 8px; margin: 8px 0 4px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--amber);
  border-radius: 99px; transition: width .5s ease;
}

.week-status { font-size: 14px; color: var(--text-dim); }
.week-dots   { display: flex; gap: 6px; margin-top: 10px; }
.week-dot    {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--bg3);
  transition: background .3s;
}
.week-dot.filled { background: var(--green); }
.week-dot.today  { background: var(--amber); }

/* ============================================================
   Live-расчёт часов / км
   ============================================================ */

.hour-calc {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 12px;
  text-align: center;
  margin-bottom: 18px;
}
.hour-calc-num   { font-size: 32px; font-weight: 800; color: var(--amber); line-height: 1; }
.hour-calc-label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ============================================================
   Таблицы
   ============================================================ */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left; padding: 10px 8px 10px 8px;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }

/* Admin dashboard — компактная */
.dash-table th { font-size: 10px; padding: 8px 5px; }
.dash-table td { padding: 10px 5px; }
.check-cell    { text-align: center; }
.check-yes     { color: var(--green); font-size: 15px; }
.check-no      { color: var(--red);   font-size: 15px; }

/* ============================================================
   Бейджи
   ============================================================ */

.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 99px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.badge-work     { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-sick     { background: rgba(239,68,68,.18);  color: var(--red);   }
.badge-vacation { background: rgba(59,130,246,.18); color: var(--blue);  }
.badge-pending  { background: rgba(245,166,35,.2);  color: var(--amber); }
.badge-approved { background: rgba(34,197,94,.2);   color: var(--green); }
.badge-denied   { background: rgba(239,68,68,.2);   color: var(--red);   }

/* ============================================================
   Иконки-кнопки (редактирование, удаление)
   ============================================================ */

.icon-btn {
  background: none; border: none; cursor: pointer;
  padding: 7px; border-radius: var(--r-sm);
  font-size: 18px; color: var(--text-dim);
  transition: color .15s; line-height: 1;
  min-width: 36px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active       { color: var(--text); }
.icon-btn.danger:active{ color: var(--red);  }

/* ============================================================
   Логин — Matrix стиль
   Все правила используют #screen-login как родитель → ID+class
   бьёт любой class без !important
   ============================================================ */

#screen-login {
  position: relative;
  background: #000;
  justify-content: center;
  align-items: center;
  padding: 32px 20px;
  min-height: 100vh;
  overflow: hidden;
}

/* Canvas дождя — полный экран, под всем */
#matrix-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* ── Карточка ── */
#screen-login .login-card {
  position: relative;
  z-index: 1;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #00ff41;
  border-radius: 16px;
  box-shadow:
    0 0 30px rgba(0, 255, 65, 0.18),
    0 0 80px rgba(0, 255, 65, 0.07),
    inset 0 0 40px rgba(0, 255, 65, 0.04);
  padding: 36px 28px 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Логотип: белая подложка + img с фильтром ── */
#screen-login .login-logo-wrap {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#screen-login .login-logo-img {
  max-width: 200px;
  width: 100%;
  height: auto;
  display: block;
  filter: brightness(1.8) contrast(1.2);
}

/* ── Заголовок «Entré Portal» ── */
#screen-login .login-title {
  font-family: 'Courier New', 'Courier', monospace;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 28px;
  line-height: 1;
  letter-spacing: 0.04em;
}
#screen-login .login-title-accent {
  color: #00ff41;
  text-shadow:
    0 0 8px  rgba(0, 255, 65, 0.95),
    0 0 20px rgba(0, 255, 65, 0.55),
    0 0 45px rgba(0, 255, 65, 0.25);
}
#screen-login .login-title-dark {
  color: #00cc34;
  text-shadow:
    0 0 6px  rgba(0, 204, 52, 0.8),
    0 0 18px rgba(0, 204, 52, 0.35);
}

/* ── Форма ── */
#screen-login .login-form { width: 100%; }

/* ── Labels — зелёные, моноширинные ── */
#screen-login .form-label {
  color: #00cc34;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.08em;
}

/* ── Поля ввода — тёмный фон, зелёный текст ── */
#screen-login .form-input {
  background: rgba(0, 18, 0, 0.85);
  border: 1px solid #00882a;
  color: #00ff41;
  font-family: 'Courier New', monospace;
  caret-color: #00ff41;
}
#screen-login .form-input:focus {
  border-color: #00ff41;
  background: rgba(0, 26, 0, 0.95);
  box-shadow: 0 0 0 3px rgba(0, 255, 65, 0.12);
  outline: none;
}
#screen-login .form-input::placeholder {
  color: #005c1a;
  opacity: 1;
}

/* ── Ошибка ── */
#screen-login .login-error {
  color: #ff4444;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  margin-bottom: 12px;
  text-align: center;
  min-height: 18px;
  text-shadow: 0 0 8px rgba(255, 68, 68, 0.6);
}

/* ── Кнопка «Logga in» ── */
#screen-login .btn-login {
  display: block;
  width: 100%;
  min-height: 52px;
  background: #00ff41;
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
  margin-top: 4px;
}
#screen-login .btn-login:hover {
  background: #33ff66;
  box-shadow:
    0 0 18px rgba(0, 255, 65, 0.65),
    0 0 40px rgba(0, 255, 65, 0.28);
}
#screen-login .btn-login:active  {
  transform: scale(.97);
  background: #00cc34;
  box-shadow: none;
}
#screen-login .btn-login:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================================
   Главный экран работника
   ============================================================ */

.welcome-banner { padding: 4px 0 4px; margin-bottom: 4px; }
.welcome-name   { font-size: 24px; font-weight: 800; line-height: 1.2; }
.welcome-date   { font-size: 14px; color: var(--text-dim); margin-top: 4px; }

/* Быстрый повтор */
.quick-repeat {
  background: linear-gradient(135deg, #0a1508, #121f0a);
  border: 1px solid rgba(34,197,94,.25);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.quick-repeat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.quick-repeat-info  { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; line-height: 1.4; }

/* ============================================================
   Мои часы — month filter
   ============================================================ */

.month-filter { margin-bottom: 16px; }
.month-filter .form-input { margin: 0; }

/* ============================================================
   Toggle (профиль — email notifications)
   ============================================================ */

.toggle {
  position: relative; display: inline-block;
  width: 50px; height: 28px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 99px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.toggle-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: var(--text-dim); border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-track              { background: var(--amber); border-color: var(--amber); }
.toggle input:checked + .toggle-track::after       { transform: translateX(22px); background: #000; }

/* ============================================================
   Toast
   ============================================================ */

#toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 99px;
  font-size: 15px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 999;
  white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
}
#toast.show           { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success        { border-color: var(--green); color: var(--green); }
#toast.error          { border-color: var(--red);   color: var(--red);   }

/* ============================================================
   Модалы
   ============================================================ */

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 200;
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
}
.modal-title   { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ============================================================
   Пустые состояния
   ============================================================ */

.empty-state {
  text-align: center; padding: 52px 16px;
  color: var(--text-dim);
}
.empty-state-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state-text { font-size: 16px; line-height: 1.6; }

/* ============================================================
   Утилиты
   ============================================================ */

.divider       { height: 1px; background: var(--border); margin: 16px 0; }
.mt-sm         { margin-top: 10px; }
.mt-md         { margin-top: 18px; }
.fw-bold       { font-weight: 700; }
.text-dim      { color: var(--text-dim); }
.text-amber    { color: var(--amber); }
.text-green    { color: var(--green); }
.text-red      { color: var(--red); }
.text-blue     { color: var(--blue); }
.flex-row      { display: flex; align-items: center; gap: 10px; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ============================================================
   Адаптив — таблет (≥600px)
   ============================================================ */

@media (min-width: 600px) {
  .content {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .tile.tile-main { grid-column: 1 / -1; }
  .modal { border-radius: var(--r); margin: auto; margin-bottom: 0; }
}
