/* ===================================================================
   Signify ID — shared styling
   Primary colours, small radii, and shadows that read like sheets of paper
   stacked on a desk rather than glowing panels.
   =================================================================== */

:root {
  --blue: #1D4ED8;
  --blue-dark: #1A3FAE;
  --blue-soft: #E9EEFB;
  --red: #C62828;
  --red-dark: #A31F1F;
  --red-soft: #FBEAEA;
  --yellow: #E0A100;
  --yellow-dark: #B57F00;
  --yellow-soft: #FDF4DC;
  --green: #1B7F4B;
  --green-soft: #E6F3EC;

  --ink: #1F2937;
  --muted: #6B7280;
  --faint: #9AA1AC;
  --line: #E2E0DB;
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --desk: #EAE8E3;

  --r: 6px;
  --r-sm: 4px;
  --r-panel: 10px;

  /* A tight contact shadow under a soft ambient one — paper on a desk. */
  --shadow-1: 0 1px 2px rgba(31,41,55,.07), 0 2px 5px rgba(31,41,55,.05);
  --shadow-2: 0 1px 2px rgba(31,41,55,.08), 0 6px 16px rgba(31,41,55,.10);
  --shadow-3: 0 1px 2px rgba(31,41,55,.09), 0 12px 30px rgba(31,41,55,.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--blue); }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- paper ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 1rem; }
.card-head {
  padding: .875rem 1.125rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1.125rem; }
.card-body.tight { padding: .75rem 1.125rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .45rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .06s ease, box-shadow .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #FCFCFB; box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-1); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.btn-primary { background: var(--blue); border-color: var(--blue-dark); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { background: var(--red); border-color: var(--red-dark); color: #fff; }
.btn-danger:hover { background: var(--red-dark); }
.btn-quiet { box-shadow: none; border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--desk); box-shadow: none; }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }

/* ---------- forms ---------- */

label { display: block; font-weight: 550; font-size: .85rem; margin-bottom: .25rem; }
.field { margin-bottom: .875rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

input[type=text], input[type=email], input[type=url], input[type=number],
input[type=search], select, textarea {
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: inset 0 1px 2px rgba(31,41,55,.04);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: inset 0 1px 2px rgba(31,41,55,.04), 0 0 0 3px var(--blue-soft);
}
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; min-width: 0; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; font-weight: 600; font-size: .74rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  padding: .5rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBFAF8; }

/* ---------- chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .45rem; border-radius: var(--r-sm);
  font-size: .76rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.chip-blue   { background: var(--blue-soft);   color: var(--blue-dark);   border-color: #C9D6F6; }
.chip-red    { background: var(--red-soft);    color: var(--red-dark);    border-color: #F0CBCB; }
.chip-yellow { background: var(--yellow-soft); color: var(--yellow-dark); border-color: #EEDFA8; }
.chip-green  { background: var(--green-soft);  color: var(--green);       border-color: #C3E2D1; }
.chip-grey   { background: var(--desk);        color: var(--muted);       border-color: var(--line); }

/* ---------- notices ---------- */

.notice {
  padding: .7rem .9rem; border-radius: var(--r);
  border: 1px solid var(--line); border-left-width: 3px;
  background: var(--surface); box-shadow: var(--shadow-1);
  margin-bottom: 1rem; font-size: .88rem;
}
.notice strong { display: block; margin-bottom: .15rem; }
.notice-warn   { border-left-color: var(--yellow); background: var(--yellow-soft); border-color: #EEDFA8; }
.notice-danger { border-left-color: var(--red);    background: var(--red-soft);    border-color: #F0CBCB; }
.notice-info   { border-left-color: var(--blue);   background: var(--blue-soft);   border-color: #C9D6F6; }
.notice-ok     { border-left-color: var(--green);  background: var(--green-soft);  border-color: #C3E2D1; }

/* ---------- centred sheet (sign-in, errors) ---------- */

.sheet-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1rem; background: var(--desk);
}
.sheet {
  width: 100%; max-width: 25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-3);
  padding: 1.75rem;
}
.sheet .brand {
  display: flex; align-items: center; gap: .55rem; margin-bottom: 1.25rem;
}
.mark {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex: none;
  background: var(--blue); box-shadow: var(--shadow-1); position: relative;
}
.mark::after {
  content: ''; position: absolute; inset: 6px 6px auto 6px; height: 3px;
  border-radius: 2px; background: var(--yellow);
  box-shadow: 0 6px 0 rgba(255,255,255,.85);
}
.brand-name { font-weight: 650; letter-spacing: -0.01em; }

/* ---------- console layout ---------- */

.app { display: grid; grid-template-columns: 15rem 1fr; min-height: 100vh; }
.side {
  background: var(--desk);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.side .brand { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  text-align: left; padding: .45rem .6rem; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-weight: 550; font-size: .875rem; color: var(--ink);
}
.nav button:hover { background: rgba(255,255,255,.65); }
.nav button.active {
  background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1);
}
.nav .nav-group {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; padding: .75rem .6rem .25rem;
}
.side .whoami {
  margin-top: auto; padding: .6rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1);
  font-size: .8rem;
}
.side .whoami .email { color: var(--muted); word-break: break-all; }

.main { padding: 1.5rem 1.75rem 4rem; max-width: 68rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); margin: 0; max-width: 48rem; }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 20rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1rem; }
.grid-2 .card + .card { margin-top: 0; }

.stat { padding: 1rem 1.125rem; }
.stat .n { font-size: 1.75rem; font-weight: 650; letter-spacing: -.02em; }
.stat .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- modal ---------- */

.modal-back {
  position: fixed; inset: 0; background: rgba(31,41,55,.35);
  display: grid; place-items: center; padding: 1.5rem; z-index: 50;
}
.modal {
  width: 100%; max-width: 34rem; max-height: 85vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-panel); box-shadow: var(--shadow-3);
}
.modal-head { padding: 1rem 1.25rem .75rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.25rem; }
.modal-foot {
  padding: .875rem 1.25rem; border-top: 1px solid var(--line);
  display: flex; gap: .6rem; justify-content: flex-end; background: #FCFCFB;
  border-radius: 0 0 var(--r-panel) var(--r-panel);
}

.perm-group { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: .75rem; }
.perm-group > h3 { margin: 0; padding: .55rem .75rem; background: #FBFAF8; border-bottom: 1px solid var(--line); font-size: .8rem; }
.perm-row {
  display: flex; align-items: center; gap: .6rem; padding: .4rem .75rem;
  border-bottom: 1px solid #F1EFEB;
}
.perm-row:last-child { border-bottom: none; }
.perm-row .label { flex: 1; font-size: .85rem; }
.perm-row select { width: auto; min-width: 7rem; }
.perm-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .55rem 1rem;
  border-radius: var(--r); box-shadow: var(--shadow-3); font-size: .875rem; z-index: 90;
}
.toast.err { background: var(--red-dark); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem;
  background: var(--desk); padding: .1rem .35rem; border-radius: var(--r-sm);
  word-break: break-all;
}
pre.code { display: block; padding: .75rem; white-space: pre-wrap; box-shadow: var(--shadow-1); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: column; border-right: none; border-bottom: 1px solid var(--line); }
  .side .whoami { margin-top: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 1.25rem 1rem 3rem; }
}
