:root {
  color-scheme: dark;
  --bg: #05080d;
  --panel: rgba(16, 24, 34, 0.72);
  --panel-strong: rgba(24, 34, 48, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f7fb;
  --muted: #9ea9b9;
  --dim: #687486;
  --orange: #e97822;
  --orange-2: #ff9b3f;
  --silver: #d9dee8;
  --steel: #9aa8b8;
  --green: #35d07f;
  --red: #ff6464;
  --shadow: rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(4, 8, 15, 0.74), rgba(4, 8, 15, 0.96)),
    url("./assets/background-dark.png") center/cover fixed no-repeat,
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.login-wrap {
  min-height: calc(100vh - 36px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(24, 32, 43, 0.88), rgba(12, 18, 27, 0.74));
  box-shadow: 0 28px 80px var(--shadow);
  backdrop-filter: blur(24px);
}

.brand {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-bottom: 18px;
  text-align: center;
}

.brand img {
  width: min(220px, 74%);
  border-radius: 8px;
}

.version {
  color: var(--orange-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.tab {
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(233, 120, 34, 0.95), rgba(255, 155, 63, 0.82));
}

.form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.36);
  outline: none;
}

.input,
.select {
  min-height: 44px;
  padding: 0 12px;
}

.textarea {
  min-height: 112px;
  padding: 12px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(255, 155, 63, 0.84);
  box-shadow: 0 0 0 3px rgba(233, 120, 34, 0.20);
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 850;
}

.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  box-shadow: 0 10px 26px rgba(233, 120, 34, 0.22);
}

.secondary {
  border: 1px solid rgba(255, 155, 63, 0.38);
  color: #ffd1ab;
  background: rgba(233, 120, 34, 0.12);
}

.ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.danger {
  border: 1px solid rgba(255, 100, 100, 0.42);
  color: #ffd5d5;
  background: rgba(255, 100, 100, 0.12);
}

.notice {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  white-space: pre-wrap;
}

.notice.good { color: #b8ffd8; border-color: rgba(53, 208, 127, 0.34); }
.notice.warn { color: #ffd2a9; border-color: rgba(255, 155, 63, 0.38); }
.notice.bad { color: #ffd2d2; border-color: rgba(255, 100, 100, 0.40); }

.desktop {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.top-card,
.panel,
.tile,
.quick-card,
.modal-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(24, 32, 43, 0.74), rgba(12, 18, 27, 0.70));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(22px);
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 22px;
  padding: 18px;
}

.side-brand {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.side-brand img {
  width: 150px;
  border-radius: 8px;
}

.side-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.nav button.active {
  color: #fff;
  background: rgba(233, 120, 34, 0.26);
  box-shadow: inset 0 0 0 1px rgba(255, 155, 63, 0.28);
}

.nav button.locked {
  color: var(--dim);
}

.side-footer {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.content {
  min-width: 0;
  display: grid;
  gap: 18px;
  align-content: start;
}

.top-card {
  border-radius: 22px;
  padding: 22px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.top-card h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.05;
}

.accent {
  color: var(--orange-2);
}

.muted {
  color: var(--muted);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 800;
}

.pill.good { color: #b7ffd6; border-color: rgba(53, 208, 127, 0.32); background: rgba(53, 208, 127, 0.10); }
.pill.warn { color: #ffd1a2; border-color: rgba(255, 155, 63, 0.35); background: rgba(233, 120, 34, 0.10); }
.pill.bad { color: #ffd0d0; border-color: rgba(255, 100, 100, 0.35); background: rgba(255, 100, 100, 0.10); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  min-height: 132px;
  border-radius: 18px;
  padding: 18px;
}

.tile small,
.quick-card small {
  color: var(--muted);
  font-weight: 700;
}

.tile strong {
  display: block;
  margin-top: 16px;
  font-size: 30px;
}

.panel {
  border-radius: 20px;
  padding: 18px;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 22px;
}

.two {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.quick-card {
  min-height: 120px;
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.quick-card:hover,
.tile:hover,
.panel:hover {
  border-color: rgba(255, 155, 63, 0.22);
}

.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.34), 0 0 26px rgba(233, 120, 34, 0.10);
}

.quick-card strong {
  display: block;
  margin: 14px 0 6px;
}

.list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.row-title {
  font-weight: 850;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
}

.ticket-row {
  align-items: start;
}

.ticket-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.signature-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.good-text {
  color: var(--green);
}

.signature-modal {
  width: min(860px, 100%);
}

.signature-canvas {
  width: 100%;
  height: min(280px, 36vh);
  display: block;
  border: 1px solid rgba(255, 155, 63, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.38);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  touch-action: none;
}

.conflict-box {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(255, 155, 63, 0.28);
  border-radius: 16px;
  background: rgba(233, 120, 34, 0.07);
}

.conflict-box h3 {
  margin: 0 0 4px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.compare-grid pre {
  max-height: 180px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
  white-space: pre-wrap;
  font-size: 12px;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inline-form .wide,
.wide {
  grid-column: 1 / -1;
}

.module-hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.54);
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 22px;
  padding: 20px;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.bar {
  height: 100%;
  width: var(--value, 0%);
  background: linear-gradient(90deg, var(--orange), var(--green));
}

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

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
  }

  .grid,
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .desktop {
    gap: 12px;
  }

  .sidebar,
  .top-card,
  .panel {
    border-radius: 18px;
    padding: 14px;
  }

  .side-brand {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .side-brand img {
    width: 104px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav button {
    min-height: 40px;
  }

  .top-card {
    display: grid;
    align-items: start;
  }

  .pill-row {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .login-wrap {
    min-height: calc(100vh - 20px);
  }

  .top-card {
    display: grid;
  }

  .grid,
  .quick-grid,
  .inline-form,
  .nav {
    grid-template-columns: 1fr;
  }

  .tile {
    min-height: 108px;
  }

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

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

  .ticket-actions,
  .button-row {
    justify-content: stretch;
  }

  .ticket-actions > *,
  .button-row > * {
    flex: 1 1 150px;
  }
}
