:root {
  --bg: #07111f;
  --bg2: #0b1728;
  --card: #111f33;
  --card2: #16263d;
  --line: #263b55;
  --text: #f5f9ff;
  --muted: #95a8bf;
  --lime: #ccff00;
  --lime-soft: rgba(204, 255, 0, 0.14);
  --cyan: #00e5ff;
  --cyan-soft: rgba(0, 229, 255, 0.12);
  --orange: #ff9900;
  --orange-soft: rgba(255, 153, 0, 0.13);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 15% 10%, rgba(204,255,0,0.10), transparent 28%),
    radial-gradient(circle at 85% 5%, rgba(0,229,255,0.12), transparent 26%),
    linear-gradient(180deg, #050b14 0%, var(--bg) 42%, #08111e 100%);
  color: var(--text);
  font-family: Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

.hidden { display: none !important; }
.small { font-size: 0.86rem; color: var(--muted); }
.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-card {
  width: 100%;
  max-width: 460px;
  background: rgba(17, 31, 51, 0.92);
  border: 1px solid rgba(204,255,0,0.22);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-top {
  padding: 28px;
  background: linear-gradient(135deg, rgba(204,255,0,0.10), rgba(0,229,255,0.08));
  border-bottom: 1px solid var(--line);
}
.brand-row { display: flex; align-items: center; gap: 14px; }
.logo-img { height: 46px; max-width: 210px; object-fit: contain; }
.logo-fallback { font-size: 1.25rem; font-weight: 900; letter-spacing: 0.08em; color: var(--lime); }
.login-title { margin: 18px 0 6px; font-size: 1.9rem; line-height: 1.1; }
.login-subtitle { margin: 0; color: var(--muted); }
.login-form { padding: 26px; display: flex; flex-direction: column; gap: 14px; }

label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  background: #091322;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 1rem;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(204,255,0,0.12);
}
textarea { resize: vertical; min-height: 86px; }
.input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.input-grid.three { grid-template-columns: 1.3fr 1fr 1fr; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  min-height: 42px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--lime); color: #07111f; box-shadow: 0 10px 28px rgba(204,255,0,0.17); }
.btn-cyan { background: var(--cyan); color: #07111f; }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn-warning { background: var(--orange); color: #07111f; }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-small { padding: 8px 10px; min-height: 34px; font-size: 0.86rem; border-radius: 10px; }
.btn-wide { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.app-shell { min-height: 100vh; }
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 17, 31, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(204,255,0,0.18);
}
.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand-title { font-size: 1.05rem; font-weight: 900; letter-spacing: 0.03em; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mobile-menu-btn { display: none; }
.user-pill {
  border: 1px solid rgba(0,229,255,0.25);
  background: rgba(0,229,255,0.07);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}
.role-tag { color: var(--lime); }
.container { max-width: 1480px; margin: 0 auto; padding: 22px 18px 42px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: linear-gradient(180deg, rgba(17,31,51,0.96), rgba(12,24,40,0.96));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14);
  position: relative;
  overflow: hidden;
}
.kpi-card:before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--cyan);
}
.kpi-card.ok:before { background: var(--lime); }
.kpi-card.warn:before { background: var(--orange); }
.kpi-card.danger:before { background: var(--red); }
.kpi-label { margin: 0 0 7px; color: var(--muted); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.06em; font-weight: 900; }
.kpi-value { font-size: 2.05rem; font-weight: 950; line-height: 1; }
.kpi-hint { margin-top: 6px; color: var(--muted); font-size: 0.82rem; }

.panel {
  background: rgba(17, 31, 51, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.panel-title { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 18px; }
.notification-list { display: grid; gap: 9px; }
.notification {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255,255,255,0.025);
}
.notification.danger { border-color: rgba(239,68,68,0.45); background: var(--red-soft); }
.notification.warning { border-color: rgba(255,153,0,0.45); background: var(--orange-soft); }
.notification.ok { border-color: rgba(204,255,0,0.35); background: var(--lime-soft); }
.notification-title { font-weight: 900; }
.notification-text { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.toolbar { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; }
.category-tools { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 10px; align-items: center; }
.category-search { max-width: 360px; }
.mobile-category-select { display: none; }
.category-empty { color: var(--muted); font-weight: 800; padding: 9px 6px; white-space: nowrap; }
.categories { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; }
.category-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}
.category-btn.active { background: var(--lime); border-color: var(--lime); color: #07111f; }
.category-btn.danger-filter.active { background: var(--red); border-color: var(--red); color: white; }
.search-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }

.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.machine-card {
  background: linear-gradient(180deg, rgba(17,31,51,0.98), rgba(13,25,41,0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 17px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  min-height: 190px;
}
.machine-card:hover { transform: translateY(-2px); border-color: rgba(204,255,0,0.45); box-shadow: 0 16px 36px rgba(0,0,0,0.20); }
.machine-card.expired { border-color: rgba(239,68,68,0.55); box-shadow: 0 0 0 1px rgba(239,68,68,0.16) inset; }
.machine-card.soon { border-color: rgba(255,153,0,0.55); }
.machine-card.inactive { opacity: 0.55; }
.card-top { display: flex; justify-content: space-between; gap: 12px; }
.machine-id { font-size: 1.24rem; color: var(--cyan); font-weight: 950; margin: 0; }
.machine-name { margin: 4px 0 10px; color: var(--text); font-weight: 800; }
.card-meta { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.status-dot { width: 13px; height: 13px; border-radius: 999px; flex: 0 0 auto; box-shadow: 0 0 12px currentColor; margin-top: 4px; }
.status-dot.ok { background: var(--lime); color: var(--lime); }
.status-dot.soon { background: var(--orange); color: var(--orange); }
.status-dot.expired { background: var(--red); color: var(--red); }
.status-dot.unknown { background: var(--muted); color: var(--muted); }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 900;
  font-size: 0.76rem;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}
.badge.ok { background: var(--lime-soft); color: var(--lime); border-color: rgba(204,255,0,0.34); }
.badge.soon, .badge.warning { background: var(--orange-soft); color: var(--orange); border-color: rgba(255,153,0,0.34); }
.badge.expired, .badge.danger { background: var(--red-soft); color: #ff9b9b; border-color: rgba(239,68,68,0.40); }
.badge.cyan { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(0,229,255,0.28); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 5, 12, 0.82);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  width: min(980px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #0d1a2c;
  border: 1px solid rgba(204,255,0,0.22);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(13, 26, 44, 0.96);
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}
.modal-title { margin: 0; color: var(--lime); font-size: 1.25rem; }
.modal-body { padding: 18px; }
.close-btn { background: transparent; border: 0; color: var(--muted); font-size: 2rem; cursor: pointer; line-height: 1; }
.section { border: 1px solid var(--line); background: rgba(255,255,255,0.025); border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.section.danger-section { border-color: rgba(239,68,68,0.42); background: var(--red-soft); }
.section-title { margin: 0 0 12px; color: var(--cyan); font-size: 1.02rem; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.detail-item { background: rgba(0,0,0,0.12); border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
.detail-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; font-weight: 900; margin-bottom: 5px; }
.detail-value { font-weight: 900; }
.task-list { display: grid; gap: 10px; }
.task-card { border: 1px solid var(--line); background: #091322; border-radius: 14px; padding: 13px; }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.task-name { font-weight: 950; }
.task-meta { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.history-list { display: grid; gap: 9px; max-height: 340px; overflow: auto; }
.history-item { border-left: 4px solid var(--cyan); background: #091322; border-radius: 12px; padding: 11px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.history-photo { max-width: 100%; max-height: 210px; border-radius: 10px; margin-top: 8px; border: 1px solid var(--line); }
.issue-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.issue-check { display: flex; align-items: center; gap: 8px; background: #091322; border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; }
.issue-check input { width: auto; }

.form-list { display: grid; gap: 10px; margin-top: 10px; }
.form-row-box { border: 1px solid var(--line); background: #091322; border-radius: 14px; padding: 12px; }
.task-form-grid { display: grid; grid-template-columns: 1.5fr 0.7fr 0.9fr 0.7fr auto; gap: 8px; align-items: end; }
.filter-form-grid { display: grid; grid-template-columns: 1.2fr 1.2fr 0.6fr auto; gap: 8px; align-items: end; }
.checkbox-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; }
.checkbox-line input { width: auto; }
.error-box { display: none; background: var(--red-soft); border: 1px solid rgba(239,68,68,0.38); color: #ffd2d2; padding: 11px; border-radius: 12px; font-weight: 800; }
.success-box { display: none; background: var(--lime-soft); border: 1px solid rgba(204,255,0,0.38); color: var(--lime); padding: 11px; border-radius: 12px; font-weight: 800; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .header { overflow: visible; }
  .header-inner { align-items: center; flex-direction: row; position: relative; padding: 9px 12px; }
  .header .brand-row { min-width: 0; gap: 9px; }
  .header .logo-img { height: 34px; max-width: 118px; }
  .header .brand-title { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58vw; }
  .header .small { display: none; }
  .mobile-menu-btn { display: inline-flex; width: auto !important; min-width: 44px; min-height: 38px; padding: 8px 12px; font-size: 1.15rem; }
  .header-actions {
    display: none;
    position: absolute;
    right: 12px;
    top: calc(100% + 8px);
    z-index: 60;
    width: min(300px, calc(100vw - 24px));
    padding: 12px;
    border: 1px solid rgba(204,255,0,0.22);
    border-radius: 16px;
    background: rgba(13,26,44,0.98);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
  }
  .header-actions.open { display: flex; }
  .header-actions .btn, .header-actions .user-pill { width: 100%; justify-content: center; }
  .header-actions .btn-small { min-height: 42px; }
  .category-tools { grid-template-columns: 1fr; }
  .category-search { display: none; }
  .mobile-category-select { display: block; }
  .categories { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-row { grid-template-columns: 1fr; }
  .input-grid, .input-grid.three, .detail-grid, .issue-grid { grid-template-columns: 1fr; }
  .task-form-grid, .filter-form-grid { grid-template-columns: 1fr; }
  .machine-grid { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .mobile-menu-btn { width: auto !important; }
  .btn-row .btn { width: auto; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-title { font-size: 1.55rem; }
  .container { padding-left: 12px; padding-right: 12px; }
  .modal-body { padding: 12px; }
}
