/* Лифты КВТ — web (как в приложении: SF Pro Text / Roboto) */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
  --primary-blue: #0089FA;
  --dark-blue: #15396B;
  --light-blue-bg: #F3FAFF;
  --light-gray-bg: #FAFAFA;
  --mid-gray: #B4B2B2;
  --white: #FFFFFF;
  --success-green: #4CAF50;
  --error: #E53935;
  --outline: #D8E4EE;
  --outline-variant: #E8F0F8;
  --card-shadow: 0 0 30px rgba(0, 0, 0, 0.10);
  --radius-card: 30px;
  --radius-pill: 9999px;
  --radius-input: 8px;
  --input-height: 40px;
  --btn-height: 44px;
  --btn-height-sm: 32px;
  --screen-padding: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', Roboto, 'Segoe UI', system-ui, sans-serif;

  /* Совместимость со старыми именами переменных */
  --primary: var(--primary-blue);
  --primary-dark: #0070cc;
  --bg: var(--light-gray-bg);
  --surface: var(--white);
  --text: var(--dark-blue);
  --muted: var(--mid-gray);
  --success: var(--success-green);
  --border: var(--outline);
  --input-radius: var(--radius-input);
  --shadow: var(--card-shadow);
}

[data-theme="dark"] {
  --dark-blue: #E2E6EB;
  --light-blue-bg: #121820;
  --light-gray-bg: #0A0E14;
  --mid-gray: #8B95A3;
  --white: #1A222D;
  --outline: #2A3340;
  --outline-variant: #1A222D;
  --primary-blue: #4A7FA8;
  --card-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
  --error: #CF6679;
  --text: var(--dark-blue);
  --muted: var(--mid-gray);
  --bg: var(--light-gray-bg);
  --surface: var(--white);
  --border: var(--outline);
}

* {
  box-sizing: border-box;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  color: var(--dark-blue);
  background: var(--light-gray-bg);
  min-height: 100vh;
}

a {
  color: var(--primary-blue);
  font-weight: 500;
}

.hidden {
  display: none !important;
}

/* --- Layout --- */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--screen-padding);
}

.page-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px var(--screen-padding);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--light-blue-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  border: 1px solid color-mix(in srgb, var(--outline) 35%, transparent);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.login-brand h1 {
  text-align: left;
}

.logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}

.login-card .logo {
  margin: 0;
}

.page-narrow:not(.login-card) .logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  margin: 0 auto 20px;
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 300;
  color: var(--dark-blue);
  text-align: center;
}

h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 300;
  color: var(--dark-blue);
}

h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-blue);
}

.subtitle {
  text-align: center;
  color: var(--mid-gray);
  margin: 0 0 20px;
  font-size: 12px;
}

.page-title {
  font-size: 28px;
  font-weight: 300;
  color: var(--dark-blue);
  margin: 0;
}

.page-title-line {
  height: 1px;
  background: var(--primary-blue);
  margin: 10px 0 20px;
}

/* --- Header --- */

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.app-header-brand {
  background: var(--light-gray-bg);
  padding: var(--screen-padding) var(--screen-padding) 0;
  max-width: 1280px;
  margin: 0 auto;
  align-items: center;
}

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

.brand img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
}

.brand h1 {
  text-align: left;
  font-size: 22px;
  margin: 0;
}

.brand .subtitle {
  text-align: left;
  margin: 4px 0 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-blue);
}

.theme-toggle {
  min-height: var(--btn-height-sm);
  padding: 6px 14px;
  font-size: 12px;
}

.app-header .btn-link {
  margin-bottom: 8px;
  display: inline-block;
}

.app-header h2 + .status-bar,
.app-header .status-bar:first-child {
  margin-top: 4px;
}

/* --- Tabs (login) --- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 16px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--mid-gray);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.tab.active {
  background: var(--white);
  color: var(--primary-blue);
  box-shadow: var(--card-shadow);
}

[data-theme="dark"] .tab.active {
  background: var(--white);
}

/* --- Fields & inputs --- */

.field {
  margin-bottom: 12px;
}

.field label,
.field-label {
  display: block;
  font-size: 12px;
  color: var(--mid-gray);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--dark-blue);
  background: var(--white);
  border: 1px solid color-mix(in srgb, var(--outline) 60%, transparent);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  min-height: var(--input-height);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--primary-blue);
  border-width: 1.5px;
}

.field input[type="date"] {
  min-height: var(--input-height);
  color: var(--dark-blue);
}

.field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}

.error {
  color: var(--error);
  margin: 12px 0;
  font-size: 13px;
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-height);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  width: 100%;
  background: var(--primary-blue);
  color: var(--white);
}

.btn-primary:not(:disabled):hover {
  opacity: 0.92;
}

.login-card .btn-primary {
  margin-top: 4px;
}

.btn-outline,
.btn-secondary {
  background: transparent;
  color: var(--primary-blue);
  border: 1.5px solid var(--primary-blue);
}

.btn-outline:not(:disabled):hover,
.btn-secondary:not(:disabled):hover {
  background: color-mix(in srgb, var(--primary-blue) 8%, transparent);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary-blue);
  cursor: pointer;
  padding: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  min-height: auto;
}

.btn-sm {
  min-height: var(--btn-height-sm) !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
}

.icon-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: var(--radius-input);
  border: 1px solid color-mix(in srgb, var(--outline) 60%, transparent);
  background: var(--white);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  color: var(--primary-blue);
  transition: border-color 0.15s, background 0.15s;
}

.icon-btn:hover {
  border-color: var(--primary-blue);
  background: color-mix(in srgb, var(--primary-blue) 8%, transparent);
}

/* --- Cards & surfaces --- */

.card,
.filters,
.menu-card,
.list,
.detail-card {
  background: var(--light-blue-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  border: 1px solid color-mix(in srgb, var(--outline) 35%, transparent);
}

.filters {
  padding: 16px 20px;
  margin-bottom: 12px;
}

.filters-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.filters-row .field {
  margin-bottom: 0;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.menu-card {
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.menu-card:hover {
  border-color: color-mix(in srgb, var(--primary-blue) 45%, var(--outline));
  transform: translateY(-1px);
}

.menu-card h3 {
  margin: 0 0 8px;
}

.menu-card p {
  margin: 0;
  color: var(--mid-gray);
  font-size: 13px;
  line-height: 1.45;
}

/* --- Lists --- */

.list {
  overflow: hidden;
  padding: 4px 0;
}

.list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 20px;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}

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

.list-item:hover {
  background: color-mix(in srgb, var(--primary-blue) 8%, transparent);
}

.list-item-static {
  cursor: default;
}

.list-item-static:hover {
  background: transparent;
}

.list-item-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

.list-item-sub {
  color: var(--mid-gray);
  font-size: 12px;
  white-space: pre-line;
  line-height: 1.45;
}

.list-item-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  border-bottom: 1px solid var(--outline-variant);
  padding: 8px 12px;
  background: transparent;
}

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

.list-item-grow {
  flex: 1;
  border-bottom: none;
  border-radius: var(--radius-input);
}

/* --- Status & progress --- */

.status-bar {
  padding: 8px 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--mid-gray);
}

.progress {
  height: 3px;
  background: var(--primary-blue);
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--mid-gray);
  font-size: 14px;
}

.badge-stopped {
  color: var(--error);
  font-weight: 600;
}

.badge-running {
  color: var(--success-green);
  font-weight: 600;
}

/* --- Detail --- */

.detail-card {
  padding: 20px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.detail-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark-blue);
  margin-top: 0;
}

.detail-card p {
  margin: 0 0 12px;
}

.detail-meta {
  color: var(--mid-gray);
  font-size: 12px;
}

.detail-media {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin-top: 16px;
  border-radius: 20px;
  background: var(--white);
  border: 1px solid var(--outline-variant);
}

/* --- Chips / badges --- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  border: none;
}

.chip-priority-high {
  color: #c62828;
  background: color-mix(in srgb, #c62828 15%, transparent);
}

.chip-priority-normal {
  color: #e65100;
  background: color-mix(in srgb, #e65100 15%, transparent);
}

.chip-priority-low {
  color: var(--success-green);
  background: color-mix(in srgb, var(--success-green) 15%, transparent);
}

.chip-status-completed {
  color: var(--primary-blue);
  background: color-mix(in srgb, var(--primary-blue) 18%, transparent);
}

.chip-status-open {
  color: var(--mid-gray);
  background: color-mix(in srgb, var(--mid-gray) 18%, transparent);
}

/* --- Toast --- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark-blue);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  z-index: 1000;
  max-width: 90vw;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--card-shadow);
}

[data-theme="dark"] .toast {
  background: #2A3340;
  color: #E2E6EB;
}

.pwa-push-banner {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-elevated, #f2f4f7);
  border: 1px solid var(--border, #d7dde5);
}

[data-theme="dark"] .pwa-push-banner {
  background: #1b2430;
  border-color: #2e3a4a;
}

.pwa-push-banner strong {
  display: block;
  margin-bottom: 8px;
}

.pwa-push-banner p {
  margin: 0 0 12px;
  color: var(--muted, #667788);
  font-size: 14px;
  line-height: 1.4;
}

.pwa-push-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pwa-push-banner button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  background: #1f6feb;
  color: #fff;
  cursor: pointer;
}

.pwa-push-banner button.secondary {
  background: transparent;
  color: inherit;
  border: 1px solid var(--border, #d7dde5);
}

.pwa-push-status {
  margin-top: 10px !important;
  margin-bottom: 0 !important;
  font-size: 13px !important;
}

@media (max-width: 720px) {
  .brand img {
    width: 52px;
    height: 52px;
  }

  .brand h1 {
    font-size: 18px;
  }

  h2 {
    font-size: 22px;
  }

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

  .menu-grid {
    grid-template-columns: 1fr;
  }

  .list-item-row {
    flex-wrap: wrap;
  }

  .list-item-row .btn-sm {
    width: 100%;
    justify-content: center;
  }
}
