/*
   * Palette, logo, control metrics and card shadow are taken from the
   * live amail.az public site (html/t/b/styles/style.css,
   * php/amail-logo.png) so this tool reads as part of the same product
   * rather than a generic admin theme.
   */
  :root {
    --green: #70C388;
    --green-dark: #5aab72;
    --blue: #4996D1;
    --blue-dark: #3a7fb8;
    --ink: #231F20;
    --muted: #6b6668;
    --faint: #9a9598;
    --line: #ECECEE;
    --field: #F5F5F5;
    --page: #F4F6F8;
    --danger: #c82333;
    --danger-bg: #FDECEE;
    --danger-line: #F3C3C9;
    --warn-bg: #FFF8E8;
    --warn-line: #F2D89A;
    --warn-ink: #7A5B00;
    --radius: 8px;
    --shadow: 0 2px 30px rgba(0, 0, 0, 0.08);
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }
  a { color: var(--blue); text-decoration: none; }
  a:hover { color: var(--blue-dark); }

  /* ---------- top bar ---------- */
  .topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .topbar .row {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 28px;
  }
  .topbar .mark { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .topbar .mark img { height: 24px; display: block; }
  .topbar .mark .div { width: 1px; height: 22px; background: var(--line); }
  .topbar .mark .sub {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.3px;
  }
  .topbar nav { display: flex; gap: 4px; margin-left: 8px; }
  .topbar nav a {
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 6px;
    line-height: 1.2;
  }
  .topbar nav a:hover { background: var(--page); color: var(--ink); }
  .topbar nav a[aria-current="page"] { background: #EAF4EE; color: var(--green-dark); }
  .topbar .who { margin-left: auto; display: flex; align-items: center; gap: 14px; }
  .topbar .who .mail { font-size: 13px; color: var(--muted); }
  /* Logout is a POST (a GET logout can be triggered by any third-party
     <img>), so it is a real button styled to match the rest of the bar. */
  .topbar .who form { display: flex; }
  .topbar .who .out {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
  }
  .topbar .who .out:hover { border-color: var(--danger-line); color: var(--danger); background: var(--danger-bg); }

  /* ---------- page frame ---------- */
  .wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
  .wrap.slim { max-width: 460px; padding-top: 72px; }
  .page-head { margin-bottom: 24px; }
  .page-head h1 { font-size: 24px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.2px; }
  .page-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 70ch; }

  .card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
  }
  .card > .head {
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
  .card > .head h2 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--faint);
    margin: 0;
  }
  .card > .body { padding: 24px; }
  .card > .body > :first-child { margin-top: 0; }
  .card > .body > :last-child { margin-bottom: 0; }

  /* ---------- forms ---------- */
  .field { display: block; margin-bottom: 18px; }
  .field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
  .field .hint { font-weight: 400; color: var(--faint); }
  input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    padding: 0 14px;
    height: 45px;
    border-radius: var(--radius);
  }
  textarea { height: auto; padding: 11px 14px; resize: vertical; line-height: 1.55; }
  input::placeholder, textarea::placeholder { color: #B6B2B4; }
  input:focus, textarea:focus, select:focus {
    outline: none;
    background: #fff;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(73, 150, 209, 0.14);
  }
  .btn {
    display: inline-block;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.2px;
    color: #fff;
    background: var(--green);
    border: 1px solid var(--green);
    padding: 12px 22px;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
  }
  .btn:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
  .btn.wide { width: 100%; }
  .btn.ghost { background: #fff; color: var(--ink); border-color: #DCDCDE; }
  .btn.ghost:hover { background: var(--page); border-color: #C9C9CC; color: var(--ink); }
  .btn.ghost.on { background: #EAF4EE; border-color: #BFE0CA; color: var(--green-dark); }
  .btn.sm { padding: 7px 14px; font-size: 13px; }
  .btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

  /* ---------- alerts ---------- */
  .alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
  }
  .alert.bad { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
  .alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }

  /* ---------- tables ---------- */
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
  thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--faint);
    padding: 12px 16px;
    background: #FAFBFC;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }
  tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover td { background: #FAFBFC; }
  td.dim { color: var(--muted); white-space: nowrap; }
  td.num { font-variant-numeric: tabular-nums; }
  thead th:first-child, tbody td:first-child { padding-left: 24px; }
  thead th:last-child, tbody td:last-child { padding-right: 24px; }
  .scroll-x { overflow-x: auto; }

  .kv { width: 100%; font-size: 14px; }
  .kv td { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .kv tr:last-child td { border-bottom: none; }
  .kv td:first-child { color: var(--muted); width: 190px; font-weight: 500; padding-left: 0; }
  .kv tr:hover td { background: transparent; }

  /* ---------- bits ---------- */
  .pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .pill.search { background: #EAF4EE; color: var(--green-dark); }
  .pill.view_mailbox { background: #E9F2FA; color: var(--blue-dark); }
  .pill.view_message { background: var(--danger-bg); color: var(--danger); }
  .pill.view_delivery { background: var(--warn-bg); color: var(--warn-ink); }

  /* delivery statuses, as Postfix names them */
  .pill.st-sent     { background: #EAF4EE; color: var(--green-dark); }
  .pill.st-bounced,
  .pill.st-reject,
  .pill.st-rejected { background: var(--danger-bg); color: var(--danger); }
  .pill.st-deferred,
  .pill.st-queued   { background: var(--warn-bg); color: var(--warn-ink); }
  .pill.on { background: #EAF4EE; color: var(--green-dark); }
  .pill.off { background: #F0F0F1; color: var(--muted); }

  pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: #FAFBFC;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    font-size: 13px;
    line-height: 1.65;
    max-height: 60vh;
    overflow: auto;
  }
  .empty { color: var(--muted); font-size: 14px; margin: 0; padding: 8px 0; }
  .pager { display: flex; gap: 16px; font-size: 14px; font-weight: 600; }

  /* ---------- small utilities (these exist so the pages carry no inline
     style attributes: the CSP below allows style-src 'self' only, with
     no 'unsafe-inline', and an inline style= attribute is exactly what
     that blocks) ---------- */
  .strong { font-weight: 600; }
  .right { text-align: right; }
  .count { font-size: 13px; color: var(--muted); }
  .flush { margin: 0; }
  .msg-meta { margin-bottom: 20px; }
  .gap-top { margin-top: 20px; }

  /* ---------- login ---------- */
  .login-mark { text-align: center; margin-bottom: 28px; }
  .login-mark img { height: 30px; }
  .login-sub {
    margin: 10px 0 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--muted);
  }
  .login-foot { text-align: center; font-size: 13px; color: var(--faint); margin: 0; }
