/*
 * Outils: the Alkemyst Atelier "night edition" look (same tokens as the website theme).
 * Deep blue-black page, charcoal panels with soft borders, light Inter type, glass and white pills.
 */

@font-face { font-family:'Inter'; font-style:normal; font-weight:300; font-display:swap; src:url('fonts/inter-latin-300.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap; src:url('fonts/inter-latin-400.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap; src:url('fonts/inter-latin-500.woff2') format('woff2'); }

:root {
  color-scheme: dark;
  --alk-night:#05070a; --alk-cream:#07090c; --alk-band:#0d1216; --alk-card:#11171c; --alk-card-2:#161e24;
  --alk-text:#eef1f4; --alk-text-2:#c3ccd3; --alk-muted:#8d9aa5;
  --alk-line:rgba(255,255,255,.09); --alk-line-strong:rgba(255,255,255,.18);
  --alk-glass:rgba(255,255,255,.06); --alk-glass-strong:rgba(255,255,255,.12);
  --alk-white:#fff; --alk-ink-on-light:#0b0f13;
  --alk-blue:#3ba6cf; --alk-blue-dark:#7cc8e6; --alk-pink:#da3675; --alk-pink-dark:#f27aa8; --alk-pink-deep:#ffa3c6;
  --alk-highlight:rgba(218,54,117,.35); --alk-open:#6fd39b;
  --alk-radius-field:14px; --alk-radius-card:24px; --alk-radius-pill:999px;
  --alk-shadow:0 30px 60px rgba(0,0,0,.45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing:border-box; }
html { background:var(--alk-night); -webkit-text-size-adjust:100%; }
body {
  margin:0; min-height:100dvh;
  background:radial-gradient(120% 60rem at 50% -10rem, rgba(29,79,99,.55), transparent 70%), var(--alk-cream);
  background-repeat:no-repeat;
  color:var(--alk-text-2); font-family:'Inter', system-ui, sans-serif; font-size:.9375rem; font-weight:300; line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
h1, h2, h3 { color:var(--alk-text); font-weight:300; letter-spacing:-.03em; line-height:1.1; margin:0 0 1rem; text-wrap:balance; }
h1 { font-size:clamp(1.9rem, 3.5vw, 2.6rem); }
h2 { font-size:1.35rem; letter-spacing:-.02em; }
strong, b, th { font-weight:500; }
a { color:var(--alk-pink-dark); text-underline-offset:.2em; transition:color .15s ease; }
a:hover { color:var(--alk-pink-deep); }
:focus-visible { outline:2px solid var(--alk-blue-dark); outline-offset:3px; }
::selection { background:var(--alk-highlight); color:var(--alk-white); }
img, svg { max-width:100%; height:auto; }
[hidden] { display:none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration:.01ms !important; animation-duration:.01ms !important; } }

/* ---------- Header and menu ---------- */
.topbar {
  position:sticky; top:0; z-index:300;
  display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:1rem;
  padding:.75rem clamp(1rem, 4vw, 2.5rem);
  background:linear-gradient(to bottom, rgba(5,7,10,.85), rgba(5,7,10,.55));
  -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border-bottom:1px solid var(--alk-line);
}
.topbar .brand { justify-self:start; display:inline-flex; align-items:center; }
.topbar .brand img { height:40px; width:auto; }
.topbar .logout { justify-self:end; margin:0; }
.login-logo { padding:3rem 1rem 0; text-align:center; }
.login-logo img { width:100%; max-width:320px; height:auto; }

.menu, .dd-list, .sub-list { list-style:none; margin:0; padding:0; }
.menu {
  display:flex; flex-wrap:wrap; align-items:center; gap:.25rem;
  padding:.3rem; border:1px solid var(--alk-line); border-radius:var(--alk-radius-pill); background:var(--alk-glass);
}
.dd { position:relative; }
.dd-trigger, .sub-trigger { font:inherit; cursor:pointer; border:0; background:none; }
.dd-trigger {
  min-height:40px; padding:.45rem 1.1rem; border-radius:var(--alk-radius-pill);
  color:var(--alk-text-2); font-weight:400;
}
.dd-trigger::after, .sub-trigger::after {
  content:""; display:inline-block; inline-size:.45rem; block-size:.45rem; margin-inline-start:.55rem;
  border-right:1.5px solid currentcolor; border-bottom:1.5px solid currentcolor;
  transform:translateY(-25%) rotate(45deg); transition:transform .15s ease;
}
.dd-trigger[aria-expanded="true"]::after, .sub-trigger[aria-expanded="true"]::after { transform:translateY(20%) rotate(225deg); }
.dd-trigger:hover, .dd-trigger[aria-expanded="true"] { color:var(--alk-white); background:var(--alk-glass-strong); }
.dd-trigger.has-current { color:var(--alk-white); box-shadow:inset 0 -2px 0 var(--alk-pink-dark); }
/* Floating panels only once menu.js is active; without script the lists stay in the flow. */
.mainnav.ready .dd-list { position:absolute; z-index:20; inset-block-start:calc(100% + .6rem); inset-inline-start:0; }
.dd-list {
  min-inline-size:16rem; max-inline-size:calc(100dvw - 2rem); padding:.5rem;
  background:rgba(17,23,28,.96); border:1px solid var(--alk-line); border-radius:var(--alk-radius-card);
  box-shadow:var(--alk-shadow); -webkit-backdrop-filter:blur(16px); backdrop-filter:blur(16px);
}
.dd-list a, .sub-trigger {
  display:block; inline-size:100%; text-align:start; padding:.55rem .85rem; border-radius:14px;
  color:var(--alk-text-2); font-weight:400; text-decoration:none;
}
.dd-list a:hover, .sub-trigger:hover { background:var(--alk-glass); color:var(--alk-white); }
.dd-list a[aria-current="page"] { color:var(--alk-white); font-weight:500; background:var(--alk-glass-strong); box-shadow:inset 3px 0 0 var(--alk-pink-dark); }
.sub-list { margin:.15rem 0 .3rem .85rem; padding-inline-start:.5rem; border-inline-start:1px solid var(--alk-line-strong); }
@media (forced-colors: active) {
  .dd-list a[aria-current="page"] { outline:2px solid CanvasText; }
  .dd-trigger.has-current { text-decoration:underline; }
}
button.link { min-height:40px; padding:.45rem 1.1rem; background:var(--alk-glass); border:1px solid var(--alk-line-strong); border-radius:var(--alk-radius-pill); color:var(--alk-text); }
button.link:hover { background:var(--alk-glass-strong); color:var(--alk-white); filter:none; }
@media (max-width: 52rem) {
  .topbar { grid-template-columns:1fr auto; }
  .mainnav { grid-column:1 / -1; grid-row:2; }
}

/* ---------- Page ---------- */
main { max-width:80rem; margin:2rem auto 4rem; padding-inline:clamp(1rem, 4vw, 2.5rem); }
.muted, .hint { color:var(--alk-muted); font-size:.9em; }

/* Panels */
.card {
  max-width:44rem; padding:clamp(1.25rem, 3vw, 2rem);
  background:linear-gradient(180deg, var(--alk-card) 0%, var(--alk-band) 100%);
  border:1px solid var(--alk-line); border-radius:var(--alk-radius-card);
}
.card.narrow { max-width:26rem; margin:2rem auto; }

/* Forms */
.row { display:flex; gap:1rem; margin-bottom:1rem; align-items:flex-start; }
.row > label { width:14rem; padding-top:.6rem; flex-shrink:0; color:var(--alk-text); font-weight:400; }
.control { flex:1; display:flex; flex-direction:column; gap:.3rem; }
.narrow .row { flex-direction:column; align-items:stretch; gap:.3rem; }
.narrow .row > label { width:auto; padding-top:0; }
input[type=text], input[type=password], input[type=number], select, textarea {
  min-height:44px; padding:.5rem .8rem;
  border:1px solid var(--alk-line-strong); border-radius:var(--alk-radius-field);
  background:var(--alk-glass); color:var(--alk-text); font:inherit; font-size:max(1rem, 1em);
}
input[type=text], input[type=password], select, textarea { width:100%; }
input[type=number] { width:5.5rem; }
select option { background:var(--alk-card); color:var(--alk-text); }
textarea { min-height:6rem; resize:vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color:var(--alk-blue-dark); }
.has-error input, .has-error select, .has-error textarea { border-color:var(--alk-pink-dark); }
.error { color:var(--alk-pink-deep); font-size:.9em; font-weight:500; }
input[type=checkbox] { inline-size:1.2rem; block-size:1.2rem; accent-color:var(--alk-pink-dark); vertical-align:middle; }

/* Buttons: the white pill, then glass pills for secondary actions. */
.actions { display:flex; gap:.6rem; align-items:center; flex-wrap:wrap; margin-top:1.25rem; }
button, .btn {
  display:inline-flex; align-items:center; justify-content:center; gap:.4rem;
  min-height:44px; padding:.65rem 1.4rem;
  background:var(--alk-white); color:var(--alk-ink-on-light); border:1px solid var(--alk-white); border-radius:var(--alk-radius-pill);
  font:500 .9375rem/1.2 'Inter', system-ui, sans-serif; text-decoration:none; cursor:pointer;
  transition:background-color .15s ease, color .15s ease, border-color .15s ease;
}
button:hover, .btn:hover { background:var(--alk-text-2); border-color:var(--alk-text-2); color:var(--alk-ink-on-light); }
button.small, .btn.small, button.mat-remove { min-height:34px; padding:.35rem .9rem; font-size:.875rem; }
.btn.small, button.small:not(.danger), button.mat-remove { background:var(--alk-glass); border-color:var(--alk-line-strong); color:var(--alk-text); }
.btn.small:hover, button.small:not(.danger):hover, button.mat-remove:hover { background:var(--alk-glass-strong); color:var(--alk-white); }
button.danger { background:transparent; border-color:var(--alk-pink-dark); color:var(--alk-pink-dark); }
button.danger:hover { background:var(--alk-pink); border-color:var(--alk-pink); color:var(--alk-white); }

/* Tables */
table {
  width:100%; border-collapse:separate; border-spacing:0;
  background:linear-gradient(180deg, var(--alk-card) 0%, var(--alk-band) 100%);
  border:1px solid var(--alk-line); border-radius:var(--alk-radius-card); overflow:hidden;
}
th, td { padding:.7rem 1rem; text-align:left; border-bottom:1px solid var(--alk-line); }
tbody tr:last-child td { border-bottom:0; }
th { color:var(--alk-text); font-size:.85em; letter-spacing:.01em; background:var(--alk-glass); }
th a { color:var(--alk-text); }
tbody tr:hover td { background:rgba(255,255,255,.025); }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; }
/* Action cells stay real table cells (display:flex on a td breaks the row height). */
td.actions { display:table-cell; margin:0; text-align:right; white-space:nowrap; }
td.actions > * { display:inline-flex; vertical-align:middle; margin:0 0 0 .35rem; }
td.actions form { margin:0 0 0 .35rem; }
tr.inactive td { color:var(--alk-muted); }

/* Messages */
.flash { padding:.8rem 1.1rem; border-radius:var(--alk-radius-field); margin-bottom:1.25rem; border:1px solid; background:var(--alk-card-2); color:var(--alk-text); }
.flash-ok { border-color:var(--alk-open); }
.flash-error { border-color:var(--alk-pink-dark); }
@media (max-width: 40rem) { .row { flex-direction:column; gap:.3rem; } .row > label { width:auto; padding-top:0; } }

/* Products list */
.tabs { display:inline-flex; gap:.25rem; margin-bottom:1rem; padding:.3rem; border:1px solid var(--alk-line); border-radius:var(--alk-radius-pill); background:var(--alk-glass); }
.tabs a { padding:.4rem 1rem; border-radius:var(--alk-radius-pill); text-decoration:none; color:var(--alk-text-2); }
.tabs a:hover { color:var(--alk-white); background:var(--alk-glass-strong); }
.tabs a.active { background:var(--alk-white); color:var(--alk-ink-on-light); font-weight:500; }
.filters { display:flex; gap:.75rem; align-items:center; flex-wrap:wrap; margin-bottom:1rem; }
.filters label { display:flex; gap:.4rem; align-items:center; }
.filters select, .filters input[type=text] { width:auto; }
.table-scroll { overflow-x:auto; margin-top:.5rem; border-radius:var(--alk-radius-card); }
.product-table td, .product-table th { white-space:nowrap; }
/* Optional columns: hidden until their box is ticked. */
.product-table :is(.ht, .col-machine, .col-filament, .col-cost) { display:none; }
#show_ht:checked ~ .table-scroll .ht,
#show_machine:checked ~ .table-scroll .col-machine,
#show_filament:checked ~ .table-scroll .col-filament,
#show_cost:checked ~ .table-scroll .col-cost { display:table-cell; }
.products > label { margin-inline:.3rem 1rem; }
.product-table tfoot td:first-child { white-space:normal; min-inline-size:12rem; }
.product-table tfoot td { font-weight:500; color:var(--alk-text); background:var(--alk-glass); border-top:1px solid var(--alk-line-strong); }
.designer { color:var(--alk-blue-dark); }

/* Product form */
.dhm { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
.product-layout { display:flex; gap:1.5rem; align-items:flex-start; flex-wrap:wrap; }
.product-layout > form.card { flex:1 1 520px; }
.breakdown { flex:0 1 340px; position:sticky; top:6rem; }
.breakdown h2 { margin:0 0 .75rem; }
.breakdown table { margin-bottom:1rem; border-radius:var(--alk-radius-field); }
.breakdown td.num { color:var(--alk-text); }
.materials-add { display:flex; gap:.5rem; align-items:center; }
.materials-list { list-style:none; margin:.6rem 0 0; padding:0; }
.materials-list li { display:flex; gap:.6rem; align-items:center; padding:.35rem .6rem; border-radius:var(--alk-radius-field); }
.materials-list li:nth-child(odd) { background:var(--alk-glass); }
.materials-list .mat-name { flex:1; color:var(--alk-text); }
.materials-list .mat-cost { font-variant-numeric:tabular-nums; }
.auth main h1 { text-align:center; }

/* Pagination: range, per-page pills, page pills. */
.pagination { display:flex; flex-wrap:wrap; align-items:center; gap:.75rem 1.5rem; margin:1rem 0; color:var(--alk-muted); font-size:.9rem; }
.pagination a { display:inline-flex; align-items:center; justify-content:center; min-inline-size:2.25rem; min-block-size:2.25rem; padding:0 .7rem; border-radius:var(--alk-radius-pill); color:var(--alk-text-2); text-decoration:none; }
.pagination a:hover { background:var(--alk-glass-strong); color:var(--alk-white); }
.pagination a[aria-current] { background:var(--alk-white); color:var(--alk-ink-on-light); font-weight:500; }
.pg-per, .pg-pages { display:inline-flex; align-items:center; gap:.2rem; padding:.2rem; border:1px solid var(--alk-line); border-radius:var(--alk-radius-pill); background:var(--alk-glass); }
.pg-per { padding-inline-start:.9rem; }
.pg-pages { margin-inline-start:auto; }
.pg-gap { padding:0 .3rem; }
@media (forced-colors: active) { .pagination a[aria-current] { outline:2px solid CanvasText; } }

/* Hover bridge: lets the pointer cross the gap between a menu button and its panel without closing it. */
.mainnav.ready .dd-list::before { content:""; position:absolute; inset-inline:0; inset-block-end:100%; block-size:.7rem; }

/* Home: one tile per tool. */
.tools { list-style:none; margin:0; padding:0; display:grid; grid-template-columns:repeat(auto-fill, minmax(16rem, 1fr)); gap:1.25rem; }
.tool {
  display:flex; flex-direction:column; gap:.6rem; block-size:100%; padding:1.75rem;
  background:linear-gradient(180deg, var(--alk-card) 0%, var(--alk-band) 100%);
  border:1px solid var(--alk-line); border-radius:var(--alk-radius-card);
  color:var(--alk-text-2); text-decoration:none; transition:border-color .15s ease, transform .15s ease, background-color .15s ease;
}
.tool:hover { border-color:var(--alk-line-strong); color:var(--alk-text-2); }
@media (prefers-reduced-motion: no-preference) { .tool:hover { transform:translateY(-2px); } }
.tool-badge {
  display:inline-grid; place-items:center; inline-size:4.5rem; block-size:4.5rem; margin-block-end:.4rem;
  border:1px solid var(--alk-line-strong); border-radius:var(--alk-radius-pill); background:var(--alk-glass);
  color:var(--alk-pink-dark);
}
.tool:hover .tool-badge { background:var(--alk-glass-strong); color:var(--alk-pink-deep); }
.tool-name { color:var(--alk-text); font-size:1.35rem; font-weight:400; letter-spacing:-.02em; }
.tool-desc { font-size:.9rem; }
