/* ============================================================================
   InstallKey — "The Key Registry" design system
   A precision-instrument identity: ink rail, cool paper, brass accent, and the
   license-key serial (IBM Plex Mono) as the signature motif.
   ========================================================================== */

:root {
  --ink:        #12262C;
  --ink-2:      #1A363D;
  --ink-3:      #24505A;
  --paper:      #E9EBE4;
  --surface:    #FBFBF7;
  --surface-2:  #F1F2EB;
  --brass:      #B58234;
  --brass-2:    #8C601E;
  --brass-tint: #EFE3C6;
  --line:       #D6D8CE;
  --line-ink:   #2C525B;
  --text:       #16242A;
  --muted:      #5D6A69;
  --inv:        #E8ECE6;
  --inv-muted:  #9DB0AE;
  --ok:         #2C6E52;
  --warn:       #9C3A2C;

  --r:    10px;
  --r-sm: 6px;
  --rail: 236px;

  --disp: "Archivo", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  --shadow: 0 1px 2px rgba(18,38,44,.05), 0 8px 24px -12px rgba(18,38,44,.18);
}

* { box-sizing: border-box; }

html { font-size: 15px; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, h4, h5 { font-family: var(--disp); font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
h3 { font-size: 1.5rem; }
a { color: var(--brass-2); text-decoration: none; }
a:hover { color: var(--ink); }

.eyebrow {
  font-family: var(--mono);
  font-size: .68rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--brass-2);
}
.mono, .serial-mono { font-family: var(--mono); }

/* ---- App shell: ink rail + workspace ------------------------------------ */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail); flex: 0 0 var(--rail);
  background: var(--ink);
  color: var(--inv);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line-ink);
}
.rail-brand { padding: 20px 20px 14px; border-bottom: 1px solid var(--line-ink); }
.rail-brand .mark {
  font-family: var(--disp); font-weight: 700; font-size: 1.15rem; color: #fff;
  display: flex; align-items: center; gap: 9px; letter-spacing: -.02em;
}
.rail-brand .mark .glyph {
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(140deg, var(--brass), var(--brass-2));
  color: var(--ink); display: grid; place-items: center;
  font-size: .9rem; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.rail-brand .sub { font-size: .7rem; color: var(--inv-muted); margin-top: 4px; letter-spacing: .02em; }

.rail-nav { padding: 12px 12px; overflow-y: auto; flex: 1; }
.rail-group + .rail-group { margin-top: 18px; }
.rail-group-label {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--inv-muted); padding: 0 10px 6px;
}
.rail-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--inv); font-size: .92rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.rail-link:hover { background: var(--ink-2); color: #fff; }
.rail-link.active { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.rail-link.sub { font-size: .86rem; color: var(--inv-muted); padding-left: 22px; }
.rail-link.sub:hover, .rail-link.sub.active { color: #fff; }

.rail-foot { padding: 12px; border-top: 1px solid var(--line-ink); }
.rail-user { font-size: .8rem; color: var(--inv-muted); padding: 2px 10px 8px; }
.rail-user strong { color: var(--inv); font-weight: 600; }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: .74rem; letter-spacing: .02em; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brass-2); }
.crumbs .sep { color: var(--line); }
.crumbs .cur { color: var(--ink); font-weight: 600; }
.page { padding: 28px; max-width: 1180px; width: 100%; }
.page-head { margin-bottom: 22px; }
.page-head h3 { margin: 2px 0 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }

/* ---- Signature: the license key-card ------------------------------------ */
.keycard {
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
  color: var(--inv); border-radius: 14px;
  border: 1px solid var(--line-ink);
  padding: 22px 24px; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.keycard::after {
  content: ""; position: absolute; inset: 0 0 auto auto;
  width: 130px; height: 130px; transform: translate(35%, -35%);
  background: radial-gradient(circle, rgba(181,130,52,.30), transparent 70%);
}
.keycard .kc-label {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--brass); margin-bottom: 14px;
}
.serial { display: flex; flex-wrap: wrap; gap: 8px; }
.serial .seg {
  font-family: var(--mono); font-weight: 600; font-size: 1.02rem; letter-spacing: .12em;
  color: #fff; background: rgba(255,255,255,.05);
  border: 1px solid rgba(181,130,52,.35); border-radius: 6px;
  padding: 7px 11px;
}
.keycard .kc-meta {
  display: flex; gap: 22px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line-ink); font-size: .8rem; color: var(--inv-muted);
}
.keycard .kc-meta b { color: var(--inv); font-family: var(--mono); font-weight: 600; }

/* inline serial treatment reused in tables/detail pages */
.serial-inline { font-family: var(--mono); letter-spacing: .06em; color: var(--ink); font-weight: 500; }

/* ---- Cards / tiles ------------------------------------------------------- */
.card, .panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card { color: var(--text); }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; display: block; color: var(--text);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tile:hover { border-color: var(--brass); transform: translateY(-2px); box-shadow: var(--shadow); color: var(--text); }
.tile .t-kicker { font-family: var(--mono); font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: var(--brass-2); }
.tile h5 { margin: 8px 0 6px; }
.tile p { color: var(--muted); font-size: .88rem; margin: 0; }

/* ---- Bootstrap component overrides (so CRUD pages inherit the identity) -- */
.btn { font-family: var(--sans); font-weight: 600; border-radius: var(--r-sm); letter-spacing: .01em; padding: .45rem .9rem; }
.btn-primary { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--brass-2); border-color: var(--brass-2); color: #fff; }
.btn-outline-primary { color: var(--brass-2); border-color: var(--brass); }
.btn-outline-primary:hover { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn-secondary { background: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-outline-secondary { color: var(--ink); border-color: var(--line); }
.btn-outline-secondary:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { background: var(--warn); border-color: var(--warn); }

.table { --bs-table-bg: transparent; color: var(--text); }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1.5px solid var(--line); font-weight: 600;
}
.table thead th a { color: var(--muted); }
.table thead th a:hover { color: var(--ink); }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: var(--surface-2); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-type: var(--brass-tint); }
.table td { border-color: var(--line); vertical-align: middle; }

.form-label { font-weight: 600; font-size: .85rem; color: var(--ink); margin-bottom: .3rem; }
.form-control, .form-select {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); padding: .5rem .7rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brass); box-shadow: 0 0 0 .18rem rgba(181,130,52,.22);
}

.badge.bg-success { background: var(--ok) !important; }
.badge.bg-warning { background: var(--brass-tint) !important; color: var(--brass-2) !important; }

.list-group-item { border-color: var(--line); background: var(--surface); }
.list-group-item-action:hover { background: var(--surface-2); }
.list-group-item.active { background: var(--ink); border-color: var(--ink); }

.pagination .page-link { color: var(--brass-2); border-color: var(--line); }
.pagination .page-item.active .page-link { background: var(--ink); border-color: var(--ink); color: #fff; }

.alert-success { background: #E4EFE7; border-color: #BEDBC7; color: var(--ok); }
.alert-danger  { background: #F5E5E1; border-color: #E4C3BB; color: var(--warn); }

.card-body { padding: 20px 22px; }
.card-title { font-family: var(--disp); }

/* ---- Focus + motion accessibility --------------------------------------- */
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn:focus, .form-control:focus, .form-select:focus { outline: none; }

@keyframes stamp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.serial .seg { animation: stamp-in .4s cubic-bezier(.2,.7,.3,1) backwards; }
.serial .seg:nth-child(1){animation-delay:.02s}.serial .seg:nth-child(2){animation-delay:.07s}
.serial .seg:nth-child(3){animation-delay:.12s}.serial .seg:nth-child(4){animation-delay:.17s}
.serial .seg:nth-child(5){animation-delay:.22s}.serial .seg:nth-child(6){animation-delay:.27s}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- Auth (split hero) --------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.auth-hero {
  background: var(--ink); color: var(--inv);
  padding: 56px 52px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 100% 0%, rgba(181,130,52,.16), transparent 55%);
}
.auth-hero .brand { font-family: var(--disp); font-weight: 700; font-size: 1.15rem; display: flex; gap: 10px; align-items: center; position: relative; }
.auth-hero .brand .glyph { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(140deg, var(--brass), var(--brass-2)); color: var(--ink); display: grid; place-items: center; }
.auth-hero h1 { color: #fff; font-size: 2.2rem; line-height: 1.05; margin: 0 0 14px; max-width: 12ch; }
.auth-hero .lede { color: var(--inv-muted); max-width: 42ch; position: relative; }
.auth-hero .hero-body { position: relative; margin: auto 0; width: 100%; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--paper); }
.auth-form .box { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 1.35rem; margin: 0 0 4px; }
.auth-form .hint { color: var(--muted); font-size: .85rem; margin: 0 0 22px; }

/* ---- Responsive: rail collapses to a top bar ---------------------------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .rail-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .rail-group, .rail-foot { display: flex; align-items: center; gap: 4px; }
  .rail-group-label, .rail-user { display: none; }
  .rail-group + .rail-group { margin-top: 0; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px; }
}
