/* ApprovalFlow — cool paper + ink, rubber-stamp statuses, mono ledger */
:root, [data-theme="light"] {
  --paper: #fafbfc;
  --card: #ffffff;
  --field: #ffffff;
  --hover: #f2f6f8;
  --ink: #16232e;
  --ink-soft: #5a6b78;
  --line: #dfe5ea;
  --approve: #0e7c66;
  --deny: #b3372f;
  --pending: #b7791f;
  --focus: #2563a8;
  --flash-ok-bg: #e4f3ee; --flash-ok-line: #bfe0d5; --flash-ok-ink: #0b5c4c;
  --flash-err-bg: #f9e8e6; --flash-err-line: #edc7c3; --flash-err-ink: #872a24;
  --radius: 8px;
  font-size: 16px;
}
[data-theme="dark"] {
  --paper: #10161c;
  --card: #18212a;
  --field: #10161c;
  --hover: #1e2a35;
  --ink: #e4ebf1;
  --ink-soft: #93a5b2;
  --line: #2b3945;
  --approve: #35b598;
  --deny: #e07067;
  --pending: #d9a24a;
  --focus: #6aa9e0;
  --flash-ok-bg: #12352c; --flash-ok-line: #1d5a4a; --flash-ok-ink: #8fd8c3;
  --flash-err-bg: #3c1f1c; --flash-err-line: #6b3530; --flash-err-ink: #f0b1aa;
}
[data-theme="dark"] body { color-scheme: dark; }
[data-theme="dark"] button, [data-theme="dark"] .btn {
  border-color: var(--line); background: #26323e;
}
[data-theme="dark"] button:hover, [data-theme="dark"] .btn:hover { background: #31404e; }
[data-theme="dark"] .btn.approve { background: #14523f; border-color: #14523f; }
[data-theme="dark"] .btn.deny { background: #79312a; border-color: #79312a; }
[data-theme="dark"] .btn.ghost { background: transparent; color: var(--ink); }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif; line-height: 1.55;
}
.mono, code, .ledger, .stamp, .chip { font-family: "IBM Plex Mono", ui-monospace, monospace; }
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
  padding: .8rem 1.5rem; background: var(--ink); color: #e9eef2;
}
.brand { font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: .02em; }
.brand span { color: #7fd6c2; }
.topbar nav { display: flex; gap: 1.2rem; flex: 1; }
.topbar nav a { color: #b9c6cf; padding: .2rem 0; border-bottom: 2px solid transparent; }
.topbar nav a.on, .topbar nav a:hover { color: #fff; border-bottom-color: #7fd6c2; text-decoration: none; }
.who { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.who a { color: #b9c6cf; }

.wrap { max-width: 980px; margin: 2rem auto 4rem; padding: 0 1.25rem; }

h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .8rem; }
.sub { color: var(--ink-soft); margin: 0 0 1.6rem; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.4rem;
}

/* forms */
label { display: block; font-weight: 600; font-size: .85rem; margin: 1rem 0 .3rem; }
label small { font-weight: 400; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=email], select, textarea, input[type=file] {
  width: 100%; padding: .55rem .7rem; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; background: var(--field);
}
input[type=file] { padding: .4rem .5rem; }
textarea { min-height: 130px; resize: vertical; }
textarea.tpl { font-family: "IBM Plex Mono", monospace; font-size: .85rem; min-height: 110px; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; margin-top: 1rem; }
.check input { width: auto; }

button, .btn {
  display: inline-block; margin-top: 1.1rem; padding: .55rem 1.3rem;
  font: inherit; font-weight: 600; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
}
button:hover, .btn:hover { background: #223546; text-decoration: none; }
.btn.approve { background: var(--approve); border-color: var(--approve); }
.btn.deny { background: var(--deny); border-color: var(--deny); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small, button.small { padding: .3rem .8rem; font-size: .82rem; margin-top: 0; }

/* the signature: rubber-stamp status */
.stamp {
  display: inline-block; padding: .1rem .55rem; font-size: .72rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; border: 2px solid;
  border-radius: 4px; transform: rotate(-2deg);
}
.stamp.approved { color: var(--approve); border-color: var(--approve); }
.stamp.denied { color: var(--deny); border-color: var(--deny); }
.stamp.pending { color: var(--pending); border-color: var(--pending); }
.stamp.big { font-size: 1.1rem; padding: .3rem 1rem; }

.chip {
  display: inline-block; font-size: .72rem; padding: .05rem .5rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft);
}

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
     color: var(--ink-soft); padding: .5rem .6rem; border-bottom: 2px solid var(--line); }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: var(--hover); }

/* ledger (audit log) */
.ledger { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.ledger li {
  display: grid; grid-template-columns: 175px 170px 1fr; gap: 1rem;
  padding: .55rem .2rem; border-bottom: 1px dashed var(--line);
}
.ledger .t { color: var(--ink-soft); }
.ledger .e { font-weight: 600; }
@media (max-width: 700px) { .ledger li { grid-template-columns: 1fr; gap: .1rem; } }

/* stat row */
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat { flex: 1 1 120px; background: var(--card); border: 1px solid var(--line);
        border-radius: var(--radius); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.5rem; font-family: "IBM Plex Mono", monospace; }
.stat span { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .92rem; }
.flash.ok { background: var(--flash-ok-bg); border: 1px solid var(--flash-ok-line); color: var(--flash-ok-ink); }
.flash.error { background: var(--flash-err-bg); border: 1px solid var(--flash-err-line); color: var(--flash-err-ink); }

/* login */
.login-box { max-width: 380px; margin: 12vh auto 0; }
.login-box .brand-lg { font-size: 1.7rem; font-weight: 700; }
.login-box .brand-lg span { color: var(--approve); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.rowline { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }
details { margin-top: .4rem; }
summary { cursor: pointer; font-size: .85rem; color: var(--focus); }
.muted { color: var(--ink-soft); font-size: .85rem; }
.pre { white-space: pre-wrap; font-size: .9rem; background: var(--hover); border: 1px solid var(--line);
       border-radius: 6px; padding: .8rem 1rem; }

@media (prefers-reduced-motion: no-preference) {
  .stamp.big { animation: stampIn .25s ease-out; }
  @keyframes stampIn { from { transform: rotate(-2deg) scale(1.6); opacity: 0; }
                       to { transform: rotate(-2deg) scale(1); opacity: 1; } }
}

/* footer */
.footer {
  max-width: 980px; margin: 0 auto; padding: 1.2rem 1.25rem 2rem;
  font-size: .8rem; color: var(--ink-soft); text-align: center;
  border-top: 1px solid var(--line);
}

/* theme toggle */
.theme-toggle {
  margin: 0; padding: .15rem .55rem; font-size: 1rem; line-height: 1;
  background: transparent; border: 1px solid #4a5b68; color: #b9c6cf;
  border-radius: 999px; cursor: pointer;
}
.theme-toggle:hover { color: #fff; border-color: #7fd6c2; background: transparent; }
.theme-toggle.floating {
  position: fixed; top: 1rem; right: 1rem; z-index: 10;
  border-color: var(--line); color: var(--ink-soft);
}
.theme-toggle.floating:hover { color: var(--ink); border-color: var(--focus); }

/* email image library */
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.imgcard { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--field); }
.imgcard img { display: block; width: 100%; height: 110px; object-fit: contain; background: #fff; }
.imgmeta { padding: .5rem .6rem; display: flex; flex-direction: column; gap: .35rem; font-size: .78rem; }
.imgmeta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imgmeta .tag {
  background: var(--hover); border: 1px dashed var(--line); border-radius: 5px;
  padding: .15rem .4rem; cursor: copy; word-break: break-all; white-space: normal;
}
