/* Pridito Admin.
   Plain on purpose: this is a tool one person uses to do a job, not a page
   anyone needs to be impressed by. Light and dark, because it gets opened at
   both ends of a day. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #dfe3e8;
  --line-soft: #edf0f3;
  --ink: #1a1d21;
  --muted: #626b75;
  --subtle: #8b949e;
  --accent: #2f6feb;
  --accent-soft: #eaf1ff;
  --ok: #1a7f45;
  --ok-soft: #e6f4ec;
  --warn: #8a6100;
  --warn-soft: #fdf3dc;
  --err: #b42318;
  --err-soft: #fdeceb;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card: #1c2024;
    --line: #2e343b;
    --line-soft: #24292e;
    --ink: #e8eaed;
    --muted: #a2acb6;
    --subtle: #6e7781;
    --accent: #6b9bff;
    --accent-soft: #1e2a3f;
    --ok: #5bc57f;
    --ok-soft: #17301f;
    --warn: #e0b34d;
    --warn-soft: #2e2617;
    --err: #f0796b;
    --err-soft: #331d1b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px 80px; }

header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; margin-bottom: 26px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
header .sub { color: var(--subtle); font-size: 13px; }
header .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

h2 {
  font-size: 13px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin: 30px 0 12px;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 16px;
}

/* ---- forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 160px; }
.row > div.narrow { flex: 0 0 120px; }

button {
  font: inherit; font-weight: 550; cursor: pointer;
  background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: 7px; padding: 9px 16px;
  white-space: nowrap;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.plain { background: var(--card); color: var(--ink); border-color: var(--line); }
button.plain:hover { background: var(--bg); filter: none; }
button.small { padding: 5px 10px; font-size: 13px; }
button.danger { background: var(--card); color: var(--err); border-color: var(--line); }
button.danger:hover { background: var(--err-soft); filter: none; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--subtle);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

code, .mono { font-family: var(--mono); font-size: 13px; }
.key {
  font-family: var(--mono); font-size: 13px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: 3px 7px; user-select: all;
}

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  border-radius: 20px; padding: 2px 9px;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.off { background: var(--err-soft); color: var(--err); }
.tag.low { background: var(--warn-soft); color: var(--warn); }
.tag.used { background: var(--line-soft); color: var(--subtle); }

.muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: 13px; }
.empty { color: var(--subtle); padding: 26px 4px; text-align: center; }
.hide { display: none !important; }

.msg {
  border-radius: 8px; padding: 11px 14px; margin: 0 0 16px;
  font-size: 14px; display: none;
}
.msg.err { display: block; background: var(--err-soft); color: var(--err); }
.msg.ok  { display: block; background: var(--ok-soft);  color: var(--ok); }

/* A batch of freshly minted codes. They exist to be copied, so they are set
   large enough to read off the screen and select in one click. */
.codes { display: grid; gap: 8px; margin-top: 14px; }
.codes .one {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 10px 12px;
}
.codes .one code { flex: 1; font-size: 16px; letter-spacing: .06em; user-select: all; }

/* ---- login ---- */
.login {
  max-width: 340px; margin: 14vh auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 26px;
}
.login h1 { margin: 0 0 4px; font-size: 19px; }
.login p { margin: 0 0 20px; color: var(--subtle); font-size: 14px; }
.login button { width: 100%; margin-top: 14px; }

/* ==========================================================================
   PHONE AND TABLET
   --------------------------------------------------------------------------
   The page assumed a wide window. What follows is the part that makes it work
   on a narrow one -- and the table rule is the whole of it, because a table is
   the one thing that cannot simply reflow.
   ========================================================================== */

/* Anything that has to stay a table can scroll sideways inside its own card
   rather than pushing the page wide. Used above the card breakpoint. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1080px) {
  .wrap { padding: 0 16px 64px; }
  header { padding: 16px; }
}

@media (max-width: 820px) {
  header { flex-wrap: wrap; gap: 10px 12px; }
  header .right { margin-left: 0; width: 100%; }
  header .right button { flex: 1; }

  /* One field per line. Two half-width fields on a 700px screen leaves neither
     wide enough to read what was typed into it. */
  .row > div,
  .row > div.narrow { flex: 1 1 100%; }

  .card { padding: 16px; border-radius: 9px; }
  h2 { margin: 24px 0 10px; }

  /* A customer takes the whole screen. At this width a modal inset on all
     sides wastes the only space there is. */
  .detail { padding: 0; }
  .detail-card { width: 100%; min-height: 100%; border-radius: 0; border: none; }
  .detail-head { position: sticky; top: 0; z-index: 2; background: var(--card); }
  .detail-body { padding: 6px 16px 40px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }

  /* Rows are cards here, so there is nothing left to scroll sideways -- and a
     scroll container around block-level cards would clip them instead. */
  .scroll-x { overflow-x: visible; }
  .wrap { padding: 0 12px 56px; }

  header { padding: 14px 12px; margin-bottom: 18px; }
  header h1 { font-size: 16px; }

  /* ---- tables become cards ----
     The header row goes, and each cell prints the column name it carries in
     data-label. Eight columns of a customer read as eight labelled lines,
     which is legible; eight columns squeezed into 380px is not. */
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; left: -9999px; }

  tr {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  tr:last-child { margin-bottom: 0; }

  td {
    display: flex; align-items: baseline; gap: 12px;
    padding: 6px 0; border-bottom: 1px solid var(--line-soft);
    text-align: left;
  }
  td:last-child { border-bottom: none; padding-bottom: 0; }
  td:first-child { padding-top: 0; }

  td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 34%;
    font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--subtle);
  }
  /* A cell whose header is blank -- the actions column -- gets the full width
     rather than a 34% gutter of nothing. */
  td:not([data-label]) { display: block; }
  td.num { text-align: left; }

  /* The activation key on its own line, at a size that can be read off the
     screen and selected in one tap. */
  .key { display: inline-block; font-size: 13px; padding: 4px 8px; word-break: break-all; }

  /* Thumbs, not cursors. These are the buttons that deactivate a customer and
     take credits back; 28px next to each other is a mis-tap waiting to happen. */
  button.small { padding: 10px 14px; font-size: 14px; min-height: 44px; }
  td button { width: 100%; }
  td button + button { margin-top: 8px; }
  input, select { min-height: 44px; }

  .codes .one { flex-wrap: wrap; }
  .codes .one code { flex: 1 1 100%; font-size: 15px; word-break: break-all; }

  .detail-head { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .detail-right { width: 100%; justify-content: space-between; }
  .detail-body { padding: 4px 12px 40px; }
  .detail-body h3 { margin: 18px 0 8px; }

  .login { margin: 8vh 16px; padding: 22px; }
}

/* A row that opens something should say so under a finger as well as a
   cursor. */
@media (hover: none) {
  .rowlink:active { background: var(--accent-soft); }
}
