:root {
  --primary: #0e3a53;
  --accent: #f26a2e;
  --ink: #12202a;
  --paper: #f7f5f1;
  --muted: #6d7780;
  --surface: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.92);
  --line: rgba(0, 0, 0, 0.08);
  --bg-page: linear-gradient(135deg, #fff8ee 0%, #f0f4f8 50%, #eaf1f5 100%);
  --topbar-bg: linear-gradient(90deg, var(--primary), #0a2d41);
  --footer-bg: #0b1f2d;
  --radius: 16px;
  --shadow: 0 12px 35px rgba(11, 28, 40, 0.12);
}

html[data-theme="dark"] {
  --ink: #f0f6fb;
  --paper: #101d2a;
  --muted: #cad7e3;
  --surface: #1a2f43;
  --surface-2: rgba(25, 45, 65, 0.97);
  --line: rgba(240, 246, 251, 0.2);
  --bg-page: radial-gradient(circle at 16% 0%, #27425b 0%, #122131 44%, #0c1825 100%);
  --topbar-bg: linear-gradient(90deg, #10273b, #0b1d2c);
  --footer-bg: #091521;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg-page);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.container {
  width: min(1180px, 92%);
  margin: 0 auto;
}

.topbar {
  background: var(--topbar-bg);
  color: #fff;
  padding: 12px 0;
}

.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 9;
  background: var(--surface-2);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.brand img {
  width: 170px;
  max-height: 54px;
  object-fit: contain;
}

.menu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.menu a {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.94rem;
}

.menu a.active,
.menu a:hover {
  background: var(--primary);
  color: #fff;
}

.mobile-menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(14, 58, 83, 0.25);
  border-radius: 12px;
  background: var(--primary);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 0;
}

.mobile-menu-toggle span {
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 999px;
}

.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 24, 0.5);
  border: 0;
  padding: 0;
  z-index: 8;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

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

html[data-theme="dark"] .brand {
  background: #eef4f9 !important;
  border: 1px solid rgba(10, 23, 35, 0.16) !important;
  border-radius: 12px;
  padding: 4px 8px;
}

html[data-theme="dark"] .hero-visual {
  background: #edf3f8 !important;
}

html[data-theme="dark"] .logo-card {
  background: #edf3f8 !important;
}

html[data-theme="dark"] .button-ghost {
  color: #eaf3fb;
  border-color: rgba(234, 243, 251, 0.34);
}

.hero {
  padding: 54px 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 30px;
  align-items: center;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

.hero-copy p {
  color: var(--muted);
  max-width: 56ch;
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.button,
button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

.button-primary,
button {
  background: var(--accent);
  color: #fff;
}

.button-ghost {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid rgba(14, 58, 83, 0.2);
}

.hero-visual {
  background: var(--surface);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero-visual img {
  border-radius: 20px;
  max-height: 340px;
  width: 100%;
  object-fit: cover;
}

.section {
  padding: 34px 0;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 1.75rem;
}

.section .lead {
  color: var(--muted);
  max-width: 68ch;
}

.cards {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

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

.product-card img {
  width: 100%;
  height: 170px;
  object-fit: contain;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.product-img-wrap {
  position: relative;
  overflow: hidden;
}

.lightbox-hint {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.product-img-wrap:hover .lightbox-hint {
  opacity: 1;
}

.product-card .button,
.product-card .button-primary {
  width: 100%;
  box-sizing: border-box;
  display: block;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.product-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.product-card .meta {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.product-card .meta strong {
  color: var(--ink);
}

.product-card .button {
  margin-top: auto;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body {
  padding: 14px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.category-card {
  min-height: 120px;
}

.category-card-body {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.category-card-body h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.category-card-body .button {
  align-self: flex-start;
}

.logo-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.logo-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-card img {
  max-width: 100%;
  max-height: 48px;
  object-fit: contain;
}

.meta {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.contact-links a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html[data-theme="dark"] .contact-links a {
  color: #8ac8ff;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 16px 0;
  background: var(--surface-2);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filters input,
.filters select,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  padding: 22px 0 40px;
}

.quick-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.quick-edit-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.quick-delete-form {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.quick-item .button,
.quick-item button {
  padding: 8px 12px;
  font-size: 0.88rem;
}

.admin-sidebar {
  background: #0f2533;
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 84px;
}

.admin-sidebar a {
  display: block;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 10px;
  border-radius: 10px;
}

.admin-sidebar a.active {
  background: var(--accent);
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

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

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 0.93rem;
}

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.notice.ok {
  background: #e7f6ec;
  color: #165b2a;
}

.notice.error {
  background: #ffe9e9;
  color: #7d1818;
}

.footer {
  margin-top: 34px;
  padding: 24px 0;
  background: var(--footer-bg);
  color: #fff;
}

.cantlibot-widget {
  position: fixed;
  right: 20px;
  bottom: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cantlibot-bubble {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.92rem;
}

.cantlibot-mobile-tip {
  display: none;
}

.cantlibot-widget img {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
  object-fit: contain;
  padding: 6px;
}

.cantlibot-widget:hover img {
  transform: translateY(-2px);
}

@media (max-width: 920px) {
  .hero-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }

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

  .admin-sidebar {
    position: static;
  }

  .cantlibot-widget {
    right: 12px;
    bottom: 12px;
  }

  .cantlibot-bubble {
    font-size: 0.83rem;
    padding: 8px 11px;
  }

  .cantlibot-widget img {
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 1200px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  .catalog-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .topbar {
    display: none;
  }

  .nav {
    z-index: 30;
  }

  .nav .container {
    padding: 8px 0;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .brand {
    min-width: 100px;
    flex: 0 0 auto;
  }

  .brand img {
    width: 106px;
    max-height: 36px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .menu {
    position: fixed;
    top: 0;
    right: 0;
    width: min(84vw, 320px);
    height: 100dvh;
    background: var(--surface-2);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    z-index: 10;
    padding: 74px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 0.24s ease;
  }

  .menu.is-open {
    transform: translateX(0);
  }

  .menu a {
    padding: 10px 12px;
    font-size: 0.92rem;
    white-space: nowrap;
    border-radius: 12px;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .hero {
    padding: 26px 0;
  }

  .section {
    padding: 22px 0;
  }

  .section h2 {
    font-size: 1.95rem;
  }

  .cards {
    margin-top: 12px;
    gap: 12px;
  }

  .category-card-body {
    min-height: 88px;
    gap: 8px;
  }

  .category-card-body h3 {
    font-size: 1.05rem;
  }

  .category-card-body .button {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .cantlibot-widget {
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    gap: 0;
    z-index: 60;
  }

  .cantlibot-bubble {
    display: none;
  }

  .cantlibot-mobile-tip {
    display: block;
    position: absolute;
    right: 60px;
    bottom: 10px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    padding: 8px 11px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: normal;
    max-width: min(62vw, 210px);
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .cantlibot-widget.show-mobile-tip .cantlibot-mobile-tip {
    opacity: 1;
    transform: translateY(0);
  }

  .cantlibot-widget img {
    width: 56px;
    height: 56px;
    padding: 5px;
    border-width: 2px;
  }

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

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