:root {
  --red: #9c1b21;
  --red-dark: #7d151a;
  --ink: #333333;
  --ink-soft: #666666;
  --line: #dcdcdc;
  --paper: #ffffff;
  --wash: #f4f4f4;
  --bar: #262626;
  --ok: #2e7d32;
  --font: "Open Sans", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--wash);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--red); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.error { color: var(--red); font-weight: 600; margin: .4em 0; }
.ok { color: var(--ok); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- top bar & brand header (as on tmfilters.com) ---------- */
.topbar { background: var(--bar); color: #ddd; font-size: 12px; }
.topbar a { color: #fff; text-decoration: none; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 6px 20px; display: flex; gap: 22px; flex-wrap: wrap; }
.topbar-right { margin-left: auto; }

.brand { background: var(--paper); border-bottom: 1px solid var(--line); }
.brand-inner { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.logo img { height: 42px; width: auto; display: block; }
.brand nav a { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; margin-left: 26px; }
.brand nav a:hover, .brand nav a.active { color: var(--red); }

/* ---------- hero with the refinery photo ---------- */
.hero { position: relative; flex: 1; background-size: cover; background-position: center 35%; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,10,10,.45) 0%, rgba(20,10,10,.15) 55%, rgba(20,10,10,.05) 100%); }
.hero-inner { position: relative; max-width: 1240px; margin: 0 auto; padding: 48px 20px 64px; min-height: 620px; display: flex; align-items: flex-start; }

/* ---------- the card (form / download list) ---------- */
.card {
  background: var(--paper);
  width: 100%;
  max-width: 480px;
  padding: 28px 28px 24px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  border-top: 4px solid var(--red);
}
.card-wide { max-width: 720px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.eyebrow-plain { color: var(--ink-soft); margin: 0 0 4px; font-size: 14px; }

/* ---------- forms ---------- */
.form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form textarea, .form select {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 2px; font: inherit; font-size: 14px; color: var(--ink); background: #fff;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }
.form textarea { min-height: 80px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.addr { display: flex; align-items: stretch; margin-top: 4px; }
.addr input { margin-top: 0 !important; border-right: 0 !important; border-radius: 2px 0 0 2px !important; }
.addr span { display: flex; align-items: center; padding: 0 11px; background: var(--wash); border: 1px solid var(--line); border-radius: 0 2px 2px 0; color: var(--ink-soft); font-size: 14px; white-space: nowrap; }

.btn {
  display: inline-block; background: var(--red); color: #fff; border: 0; border-radius: 2px;
  padding: 11px 22px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.btn:disabled { background: #b98a8c; cursor: default; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn-line { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-line:hover { background: #f8ecec; }
.btn-plain { background: transparent; color: var(--ink-soft); padding: 6px 8px; font-weight: 400; }
.btn-plain:hover { background: var(--wash); color: var(--ink); }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* recipients as chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 2px; min-height: 42px; cursor: text; }
.chips:focus-within { outline: 2px solid var(--red); outline-offset: -1px; }
.chip { background: var(--wash); border: 1px solid var(--line); border-radius: 2px; padding: 3px 6px 3px 9px; font-size: 13px; font-weight: 400; display: inline-flex; align-items: center; gap: 6px; }
.chip.bad { border-color: var(--red); color: var(--red); }
.chip button { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 15px; line-height: 1; padding: 0 2px; }
.chips input { flex: 1; min-width: 160px; border: 0 !important; padding: 4px !important; margin: 0 !important; }
.chips input:focus { outline: none !important; }

/* file drop zone and list */
.drop {
  margin-top: 4px; border: 2px dashed #c9c9c9; border-radius: 2px; padding: 18px 14px; text-align: center; cursor: pointer;
  color: var(--ink-soft); font-weight: 400; font-size: 14px; background: #fafafa;
}
.drop.over { border-color: var(--red); background: #fdf3f3; color: var(--red); }
.drop strong { color: var(--red); }
.filelist { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 2px; }
.filelist:empty { display: none; }
.filelist li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 10px; border-bottom: 1px solid #eee; font-size: 13px; font-weight: 400; }
.filelist li:last-child { border-bottom: 0; }
.filelist .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .s { color: var(--ink-soft); white-space: nowrap; }
.filelist .x { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 16px; line-height: 1; }
.filelist .x:hover { color: var(--red); }
.filelist li .bar { grid-column: 1 / -1; height: 3px; background: #eee; }
.filelist li .bar i { display: block; height: 100%; background: var(--red); width: 0; transition: width .2s; }
.filelist li.done .bar i { background: var(--ok); }
.filelist li.fail .bar i { background: #e57373; }
.summary { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-top: 6px; font-weight: 400; }
.summary.over { color: var(--red); font-weight: 600; }

/* options row */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.toggle input { width: 16px; height: 16px; }

/* progress panel */
.progress { margin: 14px 0; }
.progress .big { height: 8px; background: #eee; border-radius: 2px; overflow: hidden; }
.progress .big i { display: block; height: 100%; width: 0; background: var(--red); transition: width .25s; }
.progress .lbl { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* code entry */
.code { font-size: 28px; letter-spacing: 10px; text-align: center; font-weight: 700; }

/* link box on success */
.linkbox { display: flex; gap: 8px; margin: 10px 0 14px; }
.linkbox input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 2px; font: inherit; font-size: 13px; background: var(--wash); }

/* message quote on download page */
.message { margin: 0 0 18px; padding: 12px 16px; background: var(--wash); border-left: 3px solid var(--red); white-space: pre-wrap; }

/* file table on download page */
table.files { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
table.files td { padding: 9px 8px; border-bottom: 1px solid #eee; vertical-align: middle; }
table.files .fname { word-break: break-all; }
table.files .fsize { color: var(--ink-soft); white-space: nowrap; text-align: right; }
table.files .fact { white-space: nowrap; text-align: right; }
table.files .fact a { font-weight: 600; text-decoration: none; }
table.files .fact a:hover { text-decoration: underline; }

/* ---------- plain (manager) pages ---------- */
.page { flex: 1; max-width: 1240px; width: 100%; margin: 0 auto; padding: 26px 20px 40px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stats { display: flex; gap: 22px; font-size: 13px; color: var(--ink-soft); flex-wrap: wrap; }
.stats b { color: var(--ink); font-size: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--red); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { margin-bottom: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 12px; font-weight: 600; color: var(--ink-soft); display: block; }
.filters input, .filters select { display: block; padding: 7px 9px; border: 1px solid var(--line); border-radius: 2px; font: inherit; font-size: 13px; margin-top: 3px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; padding: 8px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; color: var(--ink-soft); font-size: 12px; }
.tbl td { padding: 8px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.tbl tr:hover td { background: #fafafa; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .nw { white-space: nowrap; }
.tbl .wrap { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl a { text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 2px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.tag-ready { background: #e6f2e7; color: var(--ok); }
.tag-uploading { background: #fff3e0; color: #b26a00; }
.tag-expired { background: #eee; color: #666; }
.tag-deleted { background: #fbe9ea; color: var(--red); }
.danger { color: var(--red); }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; }
.pager a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 2px; text-decoration: none; color: var(--ink); }
.pager a.cur { background: var(--red); color: #fff; border-color: var(--red); }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
dl.kv dt { color: var(--ink-soft); }
dl.kv dd { margin: 0; word-break: break-word; }
.inline-form { display: inline; }
.login-wrap { max-width: 420px; margin: 40px auto; }

/* ---------- footer (as on tmfilters.com) ---------- */
.foot { background: var(--ink); color: #cfcfcf; font-size: 13px; }
.foot-inner { max-width: 1240px; margin: 0 auto; padding: 34px 20px 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.foot h4 { color: #fff; font-size: 15px; margin-bottom: 10px; }
.foot p { margin: 0; line-height: 1.6; }
.foot a { color: #ff8a8f; text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot-legal { border-top: 1px solid #444; text-align: center; padding: 12px 20px; font-size: 12px; color: #999; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .foot-inner { grid-template-columns: 1fr; }
  .hero-inner { padding: 24px 12px 40px; min-height: 0; }
  .card { max-width: none; padding: 20px 16px; }
  .brand nav a { margin-left: 14px; }
  .topbar-inner span:first-child { display: none; }
  .tbl .wrap { max-width: 180px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dt { margin-top: 8px; }
}
@media (max-width: 520px) {
  .row2, .options { grid-template-columns: 1fr; }
  .card-head { flex-direction: column; }
  .logo img { height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* admin */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.admin-grid .panel { margin-bottom: 0; }
.admin-grid .panel:last-child { grid-column: 1 / -1; }
.admin-form textarea { font-family: Consolas, monospace; font-size: 13px; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: 1fr; } }

.disk-bar { height: 14px; background: #e6e6e6; border-radius: 2px; overflow: hidden; }
.disk-bar i { display: block; height: 100%; background: var(--ok); }
.disk-bar i.warn { background: #f0a020; }
.disk-bar i.crit { background: var(--red); }
.disk-lbl { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-top: 6px; flex-wrap: wrap; gap: 8px; }
