:root {
  --primary: #0168C0;
  --accent: #62D73F;
  --danger: #dc2626;
  --bg: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 22px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y pinch-zoom;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y pinch-zoom;
}

img {
  max-width: 100%;
  display: block;
}

input,
select,
textarea {
  font: inherit;
}

select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
  background: #fff;
}

textarea {
  resize: none;
}

select:focus,
textarea:focus {
  border-color: rgba(1, 104, 192, 0.6);
}

.fz-helpbar {
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.fz-helpbar.is-visible {
  display: block;
}

.fz-grid {
  display: grid;
  gap: 10px;
}

.fz-grid > * {
  min-width: 0;
}

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

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

.fz-grid-split {
  grid-template-columns: 1.2fr 0.8fr;
}

@supports (-webkit-touch-callout: none) {
  input[type="date"],
  input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-clip: padding-box;
    max-width: 100%;
  }
  input[type="date"]::-webkit-date-and-time-value {
    max-width: 100%;
  }
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  min-width: 640px;
}

.container {
  width: 92%;
  max-width: 1160px;
  margin: 0 auto;
}

.fz-bg::before {
  content: "";
  position: fixed;
  inset: -20vh -20vw;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(700px 420px at 20% 15%, rgba(1, 104, 192, 0.20), transparent 70%),
    radial-gradient(740px 520px at 85% 40%, rgba(98, 215, 63, 0.18), transparent 70%),
    radial-gradient(560px 420px at 45% 90%, rgba(1, 104, 192, 0.14), transparent 70%);
  filter: blur(14px);
  opacity: 0.9;
  transform: translate3d(0, 0, 0);
  animation: fzBgFloat 16s ease-in-out infinite;
}

@keyframes fzBgFloat {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-2%, 1.5%, 0) scale(1.05); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

.header {
  background-color: #ffffff;
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 1200;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo .accent {
  color: var(--accent);
}

.logo img {
  height: 40px;
  width: auto;
  border-radius: 10px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav a:not(.btn):not(.btn-login) {
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav a:not(.btn):not(.btn-login):hover {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn svg {
  flex: 0 0 auto;
  display: block;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 14px 32px rgba(1, 104, 192, 0.18);
}

.btn-primary:hover {
  filter: brightness(0.96);
  box-shadow: 0 16px 38px rgba(1, 104, 192, 0.22);
}

.msg-compose {
  --compose-h: 46px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.msg-compose textarea,
.msg-compose input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: var(--compose-h);
  min-height: var(--compose-h);
  max-height: var(--compose-h);
}

.msg-compose textarea {
  resize: none;
  padding: 10px 12px;
  line-height: 1.2;
}

.msg-send-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.msg-compose .btn.msg-send-btn {
  height: var(--compose-h);
  padding-top: 0;
  padding-bottom: 0;
}

.msg-send-btn svg {
  width: 18px;
  height: 18px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 14px 32px rgba(220, 38, 38, 0.18);
}

.btn-danger:hover {
  filter: brightness(0.96);
  box-shadow: 0 16px 38px rgba(220, 38, 38, 0.22);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(15, 23, 42, 0.10);
  color: var(--primary);
}

.btn-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--primary);
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 900;
  color: var(--primary);
  background: #fff;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(1, 104, 192, 0.12);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease, background-color 160ms ease, color 160ms ease;
  user-select: none;
}

.btn-login svg,
.btn-login i {
  flex: 0 0 auto;
}

.btn-login:hover {
  transform: translateY(-1px);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 14px 28px rgba(1, 104, 192, 0.18);
}

.btn-login:active {
  transform: translateY(0);
}

.btn-login:focus-visible {
  outline: 3px solid rgba(98, 215, 63, 0.25);
  outline-offset: 3px;
}

.btn-logout {
  background: transparent;
  border: 1px solid transparent;
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 12px;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.btn-logout:hover {
  color: var(--primary);
  background: rgba(1, 104, 192, 0.08);
  border-color: rgba(1, 104, 192, 0.12);
}

.btn-logout:focus-visible {
  outline: 3px solid rgba(1, 104, 192, 0.18);
  outline-offset: 2px;
}

.burger {
  display: none;
  cursor: pointer;
  z-index: 1300;
  background: none;
  border: none;
  padding: 10px;
  width: 44px;
  height: 44px;
}

.burger-line {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--primary);
  margin: 5px auto;
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 2px;
}

.burger.active .burger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.burger.active .burger-line:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}
.burger.active .burger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: -280px;
  bottom: 0;
  width: 280px;
  background: white;
  padding: 80px 24px 24px;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
  z-index: 1250;
  gap: 20px;
  transition: right 0.3s ease;
  pointer-events: none;
  visibility: hidden;
}

.mobile-nav.open {
  right: 0;
  pointer-events: auto;
  visibility: visible;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1100;
  animation: fzFadeIn 0.3s ease;
}

.overlay.active {
  display: block;
}

@keyframes fzFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.06);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.card-title i {
  color: var(--primary);
}

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

.reveal {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(2px);
  transition: opacity 620ms cubic-bezier(0.22, 1, 0.36, 1), transform 620ms cubic-bezier(0.22, 1, 0.36, 1), filter 620ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--d, 0ms);
  will-change: opacity, transform, filter;
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

footer {
  text-align: center;
  padding: 40px;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  margin-top: 60px;
}

@media (max-width: 1024px) {
  .desktop-nav { display: none; }
  .burger { display: block; }
}

@media (max-width: 640px) {
  .fz-grid-2,
  .fz-grid-3,
  .fz-grid-split {
    grid-template-columns: 1fr;
  }
}

.fz-toast-wrap {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 28px));
}

.fz-toast {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(10px);
  transform: translateY(8px);
  opacity: 0;
  animation: fzToastIn 180ms ease forwards;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.fz-toast .fz-toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 4px;
  flex: 0 0 auto;
  background: var(--primary);
}

.fz-toast.is-success .fz-toast-dot { background: #16a34a; }
.fz-toast.is-error .fz-toast-dot { background: var(--danger); }
.fz-toast.is-info .fz-toast-dot { background: var(--primary); }

.fz-toast .fz-toast-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.25;
}

.fz-toast .fz-toast-sub {
  margin-top: 3px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}

@keyframes fzToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fzToastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: rgba(255,255,255,0.98);
  animation: fzSpin 800ms linear infinite;
  display: inline-block;
}

.btn .spinner {
  border-color: rgba(15,23,42,0.18);
  border-top-color: rgba(15,23,42,0.72);
}

.btn.btn-primary .spinner,
.btn.btn-danger .spinner {
  border-color: rgba(255,255,255,0.38);
  border-top-color: rgba(255,255,255,0.98);
}

@keyframes fzSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.is-loading {
  opacity: 0.85;
  cursor: progress;
}

.field-error {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--danger);
}

.field-invalid {
  border-color: rgba(220, 38, 38, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .fz-bg::before { animation: none; }
  .reveal { transition: none; transform: none; filter: none; opacity: 1; }
  .btn { transition: none; }
}
