@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700&family=Plus+Jakarta+Sans:wght@500;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --gf-primary: #DC2626;
  --gf-primary-dark: #991B1B;
  --gf-accent: #F97316;
  --gf-accent-light: #FB923C;
  --gf-warn: #F59E0B;
  --gf-success: #16A34A;
  --gf-danger: #B91C1C;
  --gf-ink: #0F172A;
  --gf-ink-soft: #475569;
  --gf-bg: #FFF7ED;
  --gf-surface: #FFFFFF;
  --gf-border: #FED7AA;
  --gf-header-gradient: linear-gradient(135deg, #DC2626 0%, #F97316 100%);
  --gf-shadow-sm: 0 10px 28px rgba(124, 45, 18, .08);
  --gf-shadow-md: 0 20px 60px rgba(124, 45, 18, .14);
  --gf-radius-card: 18px;
  --gf-radius-button: 10px;
  --gf-radius-input: 8px;
  --gf-z-base: 1;
  --gf-z-sidebar: 40;
  --gf-z-drawer: 300;
  --gf-z-bottom-nav: 500;
  --gf-z-modal: 5000;
  --gf-z-toast: 6000;
  --gf-z-offline: 6100;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--gf-bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--gf-ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(249, 115, 22, .20), transparent 30rem),
    radial-gradient(circle at 92% 8%, rgba(220, 38, 38, .13), transparent 26rem),
    linear-gradient(120deg, rgba(255, 247, 237, .96), rgba(255, 237, 213, .72));
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  mix-blend-mode: multiply;
  background-image:
    linear-gradient(90deg, rgba(153, 27, 27, .08) 1px, transparent 1px),
    linear-gradient(rgba(153, 27, 27, .06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
  z-index: -1;
}

h1, h2, h3, .gf-heading { font-family: 'Plus Jakarta Sans', Inter, sans-serif; letter-spacing: -.03em; text-wrap: balance; }
code, .mono { font-family: 'JetBrains Mono', monospace; }
[x-cloak] { display: none !important; }

.gf-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.gf-sidebar {
  position: sticky; top: 0; height: 100vh; padding: 18px;
  z-index: var(--gf-z-sidebar);
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,247,237,.72));
  border-right: 1px solid rgba(254, 215, 170, .95);
  backdrop-filter: blur(18px);
}
.gf-main { min-width: 0; padding: 22px clamp(16px, 3vw, 38px) 96px; }
.gf-topbar {
  min-height: 72px; border-radius: 22px; padding: 14px 18px; color: white;
  background: var(--gf-header-gradient); box-shadow: var(--gf-shadow-md);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.gf-logo { width: 42px; height: 42px; border-radius: 14px; background: white; padding: 5px; box-shadow: 0 8px 20px rgba(127, 29, 29, .22); }
.gf-nav { display: grid; gap: 8px; margin-top: 22px; }
.gf-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 12px;
  color: var(--gf-ink); text-decoration: none; border-radius: 14px; font-weight: 700;
}
.gf-nav a:hover, .gf-nav a.active { background: rgba(220, 38, 38, .10); color: var(--gf-primary-dark); }
.gf-bottom-nav { display: none; }

.gf-card {
  background: color-mix(in srgb, var(--gf-surface) 94%, #FFF7ED);
  border: 1px solid rgba(254, 215, 170, .95);
  border-radius: var(--gf-radius-card);
  box-shadow: var(--gf-shadow-sm);
}
.gf-card.pad { padding: clamp(16px, 2vw, 24px); }
.gf-stat { position: relative; overflow: hidden; }
.gf-stat::after { content: ""; position: absolute; inset: auto -30px -42px auto; width: 110px; height: 110px; border-radius: 999px; background: rgba(249, 115, 22, .14); }
.gf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 16px; border: 0; border-radius: var(--gf-radius-button); font-weight: 800; cursor: pointer;
  transition: transform .16s cubic-bezier(.16,1,.3,1), box-shadow .16s, background .16s;
}
.gf-btn:focus-visible, .gf-input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--gf-accent) 40%, white); outline-offset: 2px; }
.gf-btn:active { transform: translateY(1px) scale(.99); }
.gf-btn.primary { color: white; background: var(--gf-header-gradient); box-shadow: 0 12px 26px rgba(220, 38, 38, .26); }
.gf-btn.secondary { color: var(--gf-primary-dark); background: #FFEDD5; }
.gf-btn.ghost { color: var(--gf-ink); background: rgba(255,255,255,.68); border: 1px solid var(--gf-border); }
.gf-btn.danger { color: white; background: var(--gf-danger); }
.gf-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.gf-input, select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--gf-border); border-radius: var(--gf-radius-input);
  padding: 10px 12px; background: white; color: var(--gf-ink); font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
.gf-label { display: block; margin-bottom: 6px; font-weight: 800; font-size: .86rem; color: var(--gf-ink); }
.gf-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.gf-table th { text-align: left; font-size: .75rem; color: var(--gf-ink-soft); text-transform: uppercase; letter-spacing: .06em; padding: 0 10px; }
.gf-table td { background: white; border-top: 1px solid var(--gf-border); border-bottom: 1px solid var(--gf-border); padding: 12px 10px; }
.gf-table td:first-child { border-left: 1px solid var(--gf-border); border-radius: 12px 0 0 12px; }
.gf-table td:last-child { border-right: 1px solid var(--gf-border); border-radius: 0 12px 12px 0; }
.gf-badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 4px 10px; font-size: .78rem; font-weight: 800; background: #FFEDD5; color: var(--gf-primary-dark); }
.gf-badge.green { background: #DCFCE7; color: #166534; }
.gf-badge.red { background: #FEE2E2; color: #991B1B; }
.gf-badge.gray { background: #F1F5F9; color: #334155; }
.gf-grid { display: grid; gap: 16px; }
.gf-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gf-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gf-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gf-map, #map, #miniMap { min-height: 560px; border-radius: 22px; overflow: hidden; border: 1px solid var(--gf-border); }
.gf-drawer { position: fixed; inset: 90px 18px 18px auto; width: min(420px, calc(100vw - 36px)); z-index: var(--gf-z-drawer); }
.gf-toast-wrap { position: fixed; top: 18px; right: 18px; z-index: var(--gf-z-toast); display: grid; gap: 10px; width: min(380px, calc(100vw - 36px)); }
.gf-toast { padding: 14px 16px; border-radius: 16px; color: white; font-weight: 800; box-shadow: var(--gf-shadow-md); animation: gf-slide .22s cubic-bezier(.16,1,.3,1); }
.gf-toast.success { background: var(--gf-success); }
.gf-toast.error { background: var(--gf-danger); }
.gf-offline { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: var(--gf-z-offline); padding: 10px 14px; border-radius: 999px; color: white; background: var(--gf-ink); box-shadow: var(--gf-shadow-md); font-weight: 800; }
.gf-core-chip { min-height: 38px; border-radius: 10px; padding: 7px 9px; border: 1px solid rgba(15,23,42,.12); background: white; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.gf-core-chip.selected { outline: 3px solid rgba(249,115,22,.35); }
.gf-core-color { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(15,23,42,.22); }
.gf-core-chip.broken { opacity: .55; text-decoration: line-through; }

@keyframes gf-slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.gf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--gf-z-modal);
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(12px);
}
.gf-modal-panel {
  width: min(720px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  overflow: auto;
  position: relative;
  z-index: calc(var(--gf-z-modal) + 1);
}
body.gf-modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 960px) {
  .gf-shell { display: block; }
  .gf-sidebar { display: none; }
  .gf-main { padding: 14px 14px 86px; }
  .gf-grid.cols-4, .gf-grid.cols-3, .gf-grid.cols-2 { grid-template-columns: 1fr; }
  .gf-bottom-nav { position: fixed; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); z-index: var(--gf-z-bottom-nav); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px; border-radius: 22px; background: rgba(255,255,255,.96); border: 1px solid var(--gf-border); box-shadow: var(--gf-shadow-md); backdrop-filter: blur(16px); }
  .gf-bottom-nav a { min-height: 48px; display: grid; place-items: center; text-decoration: none; color: var(--gf-ink-soft); font-weight: 800; font-size: .72rem; border-radius: 14px; }
  .gf-bottom-nav a.active { color: white; background: var(--gf-header-gradient); }
  .gf-map, #map, #miniMap { min-height: 460px; }
}
