/* TKC Webmail – The Kensington Constabulary
   Brand blue: C91 M80 Y38 K39 (matches the navy in the supplied logo, #2C3152). */
:root {
  --navy: #2C3152;
  --navy-deep: #20243f;
  --navy-soft: #454b73;
  --gold: #be9844;
  --steel: #a6b7c4;
  --ink: #1d2030;
  --muted: #5d6478;
  --line: #d9dee6;
  --bg: #eef1f5;
  --paper: #ffffff;
  --unread: #f6f8fc;
  --error: #9c1c1c;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn-primary {
  background: var(--navy); color: #fff; border: 0; border-radius: 3px;
  padding: 12px 20px; font-weight: 600; letter-spacing: .04em; width: 100%;
}
.btn-primary:hover { background: var(--navy-deep); }

/* ================= Login ================= */
body.is-login { background: var(--navy); min-height: 100vh; min-height: 100dvh; }
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 16px; gap: 22px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--paper); border-top: 5px solid var(--gold);
  border-radius: 4px; padding: 32px 32px 30px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.login-logo { display: block; width: 168px; height: auto; margin: 0 auto 14px; }
.login-title {
  margin: 0 0 22px; text-align: center; font-size: 13px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.login-title::before, .login-title::after { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--line); vertical-align: middle; margin: 0 10px; }
.login-fields label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin: 14px 0 5px; }
.login-fields input, .lock-card input {
  display: block; width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 10px 12px; border: 1px solid #b7bfcc; border-radius: 3px; background: #fff;
}
.login-fields input:focus, .lock-card input:focus { border-color: var(--navy); outline: 2px solid rgba(44, 49, 82, .25); outline-offset: 0; }
.masked { -webkit-text-security: disc; text-security: disc; letter-spacing: .08em; }
.login-fields .btn-primary { margin-top: 22px; text-transform: uppercase; }
.login-error {
  margin-top: 20px; padding: 14px 16px; border: 1px solid #e3b5b5; border-left: 4px solid var(--error);
  background: #fdf3f3; color: #5e1414; font-size: 13.5px; border-radius: 2px; overflow-wrap: anywhere;
}
.login-error strong { display: block; color: var(--error); letter-spacing: .02em; }
.login-error p { margin: 8px 0 2px; }
.login-error ul { margin: 0; padding: 0; list-style: none; }
.login-error li { padding-left: 14px; text-indent: -14px; }
.login-error li::before { content: "- "; }
.login-foot { max-width: 400px; margin: 0; text-align: center; font-size: 12px; color: var(--steel); }

/* ================= Mailbox shell ================= */
body.is-app { height: 100vh; height: 100dvh; overflow: hidden; }
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--navy); color: #fff; padding: 8px 18px; border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 37px; height: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: .09em; text-transform: uppercase; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--steel); letter-spacing: .06em; }
.account { display: flex; align-items: center; gap: 14px; flex: none; }
.account-name { font-size: 13px; color: #dfe5ee; }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .45); border-radius: 3px; padding: 6px 12px; font-size: 13px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); }

.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 370px) 1fr; }
.list-pane { min-width: 0; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { flex: none; display: flex; align-items: baseline; justify-content: space-between; padding: 14px 18px 12px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 19px; color: var(--navy); }
.count { font-size: 12.5px; color: var(--muted); }
.mail-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.mail-row {
  display: block; padding: 11px 18px 12px 15px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent;
  text-decoration: none; color: var(--ink);
}
.mail-row:hover { background: #f3f5f9; }
.mail-row.unread { background: var(--unread); border-left-color: var(--gold); }
.mail-row.active { background: #e4e8f1; border-left-color: var(--navy); }
.row-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.row-from { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-date { flex: none; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.row-subject { display: block; font-size: 14px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-preview { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread .row-from, .unread .row-subject { font-weight: 700; }
.unread .row-date { color: var(--navy); font-weight: 600; }
.clip { width: 15px; height: 15px; vertical-align: -2px; flex: none; }

/* ================= Reading pane ================= */
.read-pane { overflow-y: auto; min-height: 0; min-width: 0; background: var(--bg); }
.read-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.read-empty img { width: 110px; height: auto; opacity: .22; filter: grayscale(1); }
.read-empty p { margin: 0; }
.msg { max-width: 860px; margin: 22px auto; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; padding: 26px 32px 30px; }
.back { display: none; }
.msg-subject { margin: 0 0 14px; font-size: 22px; line-height: 1.25; color: var(--navy); }
.msg-subject .clip { width: 19px; height: 19px; color: var(--muted); }
.msg-head, .qhead { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; font-size: 13.5px; }
.msg-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.msg-head dt, .qhead dt { font-weight: 700; color: var(--navy); }
.msg-head dd, .qhead dd { margin: 0; overflow-wrap: anywhere; }
.msg-body { padding-top: 18px; font-size: 15.5px; line-height: 1.6; }
.msg-body p { margin: 0 0 14px; }
.msg-body .sig { color: var(--muted); font-size: 14px; margin-top: 4px; overflow: hidden; }
.quoted { margin-top: 22px; padding-top: 16px; border-top: 1px solid #b9c0cc; }
.quoted .qhead { margin-bottom: 16px; }
.excerpt-label { font-weight: 700; letter-spacing: .04em; margin-bottom: 8px !important; }
.inline-img { display: block; padding: 0; margin: 0 0 18px; border: 1px solid var(--line); background: #fff; max-width: 620px; width: 100%; cursor: zoom-in; }
.inline-img img { display: block; width: 100%; height: auto; }

.atts { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.atts h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.att-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.att-card {
  display: flex; align-items: center; gap: 12px; text-align: left; background: #f6f7fa; border: 1px solid var(--line);
  border-radius: 3px; padding: 8px 14px 8px 8px; max-width: 100%; min-width: 250px;
}
.att-card:hover { border-color: var(--navy-soft); background: #eef1f7; }
.att-thumb { width: 64px; height: 64px; object-fit: cover; object-position: top; border: 1px solid var(--line); background: #fff; flex: none; }
.att-icon { width: 64px; height: 64px; flex: none; display: grid; place-items: center; background: #e3efe6; color: #2f6b45; border: 1px solid #c5dccb; }
.att-icon svg { width: 34px; height: 34px; }
.att-info { display: flex; flex-direction: column; min-width: 0; }
.att-name { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.att-size { font-size: 12.5px; color: var(--muted); }

/* Audio attachment */
.audio-card { display: flex; width: 100%; max-width: 620px; background: var(--navy); color: #fff; border-radius: 4px; overflow: hidden; }
.audio-cover { width: 190px; flex: none; object-fit: cover; object-position: 30% center; }
.audio-body { flex: 1; min-width: 0; padding: 14px 16px 14px; }
.audio-file { font-size: 12.5px; color: var(--steel); display: flex; align-items: center; gap: 5px; }
.audio-title { font-size: 17px; font-weight: 700; margin-top: 4px; line-height: 1.25; }
.audio-meta { font-size: 13px; color: #d5dbe6; }
.audio-ctrl { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.audio-play { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--gold); color: var(--navy-deep); display: grid; place-items: center; padding: 0; }
.audio-play:hover { background: #d0ab58; }
.audio-play svg { width: 22px; height: 22px; fill: currentColor; }
.i-pause { display: none; }
.playing .i-pause { display: inline; }
.playing .i-play { display: none; }
.audio-seek { flex: 1; min-width: 0; accent-color: var(--gold); }
.audio-time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: #d5dbe6; flex: none; }
.audio-msg { margin-top: 8px; font-size: 13px; color: #ffd9a8; }

/* ================= Attachment viewer ================= */
.viewer { position: fixed; inset: 0; z-index: 50; background: #171a2c; display: flex; flex-direction: column; }
.viewer-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 8px 18px; color: #fff; background: var(--navy-deep); }
.viewer-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-tools { display: flex; align-items: center; gap: 14px; flex: none; }
.viewer-tools button { width: 38px; height: 38px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .3); background: transparent; color: #fff; font-size: 20px; line-height: 1; padding: 0; }
.viewer-tools button:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.viewer-tools button:disabled { opacity: .35; cursor: default; }
.viewer-pager, .viewer-zoom { display: inline-flex; align-items: center; gap: 6px; }
#vPage { font-size: 13px; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.viewer-close { font-size: 16px !important; }
.viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 12px; -webkit-overflow-scrolling: touch; }
.viewer-stage img { margin: auto; display: block; flex: none; max-width: none; background: #fff; cursor: zoom-in; box-shadow: 0 6px 30px rgba(0, 0, 0, .5); }
.viewer-stage img.zoomed { cursor: zoom-out; }

.lock-card { margin: auto; width: 100%; max-width: 360px; background: #fff; border-radius: 4px; border-top: 5px solid var(--gold); padding: 26px 28px 28px; text-align: center; }
.lock-icon { width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%; background: #eef1f5; color: var(--navy); display: grid; place-items: center; }
.lock-icon svg { width: 28px; height: 28px; }
.lock-card h2 { margin: 0; font-size: 18px; color: var(--navy); }
.lock-card p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.lock-card label { display: block; text-align: left; font-size: 13px; font-weight: 600; color: var(--navy); margin: 18px 0 5px; }
.lock-card .lock-err { color: var(--error); text-align: left; margin-top: 8px; }
.lock-card .btn-primary { margin-top: 18px; }

.sheet-wrap { margin: 0 auto; background: #fff; align-self: flex-start; max-width: 100%; overflow-x: auto; box-shadow: 0 6px 30px rgba(0, 0, 0, .5); }
.sheet { border-collapse: collapse; font-size: 14px; font-family: Calibri, "Segoe UI", Arial, sans-serif; color: #1c1c1c; }
.sheet th, .sheet td { border: 1px solid #d4d7dc; padding: 5px 12px; text-align: left; white-space: nowrap; font-weight: 400; }
.sheet .col, .sheet .corner, .sheet .rn { background: #eef0f3; color: #666d7a; text-align: center; font-size: 12px; padding: 3px 8px; font-weight: 400; }
.sheet .rn { width: 34px; }
.sheet .s-title td { font-size: 21px; font-weight: 700; color: #fff; background: #2f6b45; border-color: #2f6b45; padding: 10px 12px 2px; }
.sheet .s-sub td { font-size: 16px; font-weight: 600; color: #fff; background: #2f6b45; border-color: #2f6b45; padding-top: 0; }
.sheet .s-upd td { color: #dcebdf; background: #2f6b45; border-color: #2f6b45; font-size: 13px; padding-top: 0; padding-bottom: 10px; }
.sheet .s-note td { font-style: italic; color: #444; background: #f4f8f5; white-space: normal; }
.sheet .s-head th:not(.rn) { font-weight: 700; background: #dcebdf; color: #1d4a2e; border-bottom: 2px solid #2f6b45; }
.sheet tbody tr:nth-child(n+6):nth-child(even) td { background: #f8faf8; }
.sheet td.code { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 14px; letter-spacing: .03em; }

/* ================= Small screens ================= */
@media (max-width: 820px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .read-pane { display: none; }
  body.reading .list-pane { display: none; }
  body.reading .read-pane { display: block; }
  .account-name { display: none; }
  .brand-name { font-size: 12px; letter-spacing: .06em; }
  .topbar { padding: 8px 12px; }
  .msg { margin: 0; border: 0; border-radius: 0; padding: 14px 16px 28px; min-height: 100%; }
  .back { display: inline-block; margin: 0 0 12px -4px; padding: 6px 10px 6px 4px; color: var(--navy); font-weight: 600; text-decoration: none; }
  .msg-subject { font-size: 19px; }
  .read-pane { background: var(--paper); }
  .att-card { width: 100%; }
  .viewer-tools { gap: 8px; }
  .viewer-bar { padding-left: 12px; }
  .login-card { padding: 26px 22px 24px; }
}
@media (max-width: 480px) {
  .audio-card { flex-direction: column; }
  .audio-cover { width: 100%; height: 150px; object-position: center 30%; }
}
