/* Pastas - Root of Business visual system:
   navy dominant, silver structural, sepia accent, Trebuchet MS, square corners. */

:root {
  --navy: #1B365D;
  --navy-dark: #132744;
  --navy-tint: #E6ECF4;   /* selected row */
  --navy-hover: #F2F5F9;  /* row under the mouse */
  --silver: #C0C0C0;
  --sepia: #C4A87C;
  --sepia-bg: #FAF7F2;
  --sepia-border: #D8CEBC;
  --sepia-rule: #E5DDD0;
  --text: #1E1E1E;
  --muted: #808080;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; border-radius: 0; }

html, body { height: 100%; margin: 0; }

body { background: #fff; overflow: hidden; }

img[src$=".svg"] { filter: none !important; }

button, select, input, textarea { font: inherit; color: inherit; }

button, select {
  background: #fff;
  border: 1px solid var(--silver);
  padding: 5px 12px;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--navy); background: var(--navy-hover); }
button:disabled, select:disabled { opacity: 0.45; cursor: default; }

.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.btn-navy:hover:not(:disabled) { background: var(--navy-dark); border-color: var(--navy-dark); }

.grow { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--sepia-rule); margin: 0 4px; }

.pre-title {
  color: var(--sepia);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.pre-title span { margin-right: 3px; }

/* ---------- show login OR app, never both ---------- */
body.signed-out .app { display: none; }
body:not(.signed-out) .login { display: none; }

/* ---------- login page ---------- */
.login {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) 7fr;
  height: 100%;
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--navy);
  padding: 56px;
  overflow: hidden;
}

.login-logo { width: 260px; max-width: 100%; height: auto; position: relative; z-index: 1; }

.login-fractal {
  position: absolute;
  right: -80px;
  bottom: -60px;
  width: 460px;
  height: auto;
  opacity: 0.35;
}

.login-tagline {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--silver);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #FDFBF8 0%, var(--sepia-bg) 100%);
  border-left: 1px solid var(--sepia-rule);
  padding: 40px 24px;
}

.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--sepia-border);
  padding: 44px 40px 36px;
  box-shadow: inset 0 0 60px rgba(196, 168, 124, 0.05);
}

.login-box h1 {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
}

.login-text { margin: 0 0 28px; color: var(--muted); font-size: 16px; line-height: 1.6; }

.login-box .btn-navy { width: 100%; padding: 12px 16px; font-size: 16px; }

.login-note {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--sepia-rule);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-foot { margin: 24px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- app frame ---------- */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  padding: 0 14px;
  background: var(--navy);
  color: #fff;
}

.top-logo { height: 34px; width: auto; }

.brand {
  min-width: 120px;
  padding-left: 14px;
  border-left: 1px solid rgba(192, 192, 192, 0.4);
  font-size: 17px;
  font-weight: 700;
}

.search { flex: 1; max-width: 560px; }
.search input { width: 100%; border: 1px solid transparent; padding: 7px 10px; }
.search input:focus { outline: 2px solid var(--sepia); outline-offset: -2px; }

.account { margin-left: auto; color: var(--silver); font-size: 13px; }

.top-btn { background: transparent; border-color: rgba(192, 192, 192, 0.6); color: #fff; }
.top-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); border-color: #fff; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 14px;
  background: #fff;
  border-bottom: 1px solid var(--sepia-rule);
}

/* ---------- folders | (list above reading pane) ---------- */
.panes {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}

.folders {
  background: var(--sepia-bg);
  border-right: 1px solid var(--sepia-rule);
  overflow-y: auto;
  padding: 8px 0;
}

.folder {
  display: flex;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 16px;
  text-align: left;
}

.folder:hover:not(:disabled) { background: #F3ECE0; border: 0; }
.folder.active { background: var(--navy-tint); box-shadow: inset 3px 0 0 var(--navy); color: var(--navy); font-weight: 700; }
.folder .count { margin-left: auto; color: var(--navy); font-weight: 700; }
.folder-gap { height: 1px; background: var(--sepia-rule); margin: 8px 12px; }

.mail-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.list-pane {
  display: flex;
  flex-direction: column;
  flex: 0 0 42%;
  min-height: 140px;
  border-bottom: 2px solid var(--sepia-rule);
}

.list-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--sepia-rule);
  color: var(--navy);
  font-weight: 700;
}

.list-head button { padding: 0 9px; font-size: 16px; line-height: 22px; }
#page-info { font-weight: 400; color: var(--muted); font-size: 12px; }

.list { flex: 1; overflow-y: auto; outline: none; }

/* One line per email: tick | from | subject | date */
.row-msg {
  display: grid;
  grid-template-columns: 20px minmax(140px, 220px) 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 6px 14px 6px 11px;
  border-bottom: 1px solid #EFEAE2;
  border-left: 3px solid transparent;
  cursor: default;
  user-select: none;
}

.row-msg:hover { background: var(--navy-hover); }
.row-msg.selected { background: var(--navy-tint); }
.row-msg.unread { border-left-color: var(--navy); }
.row-msg.unread .from, .row-msg.unread .subject { font-weight: 700; color: var(--text); }
.row-msg.unread .date { color: var(--navy); font-weight: 700; }

.row-msg input { margin: 0; }
.row-msg .from, .row-msg .subject { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-msg .subject { color: #4A4A4A; }
.row-msg .date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-msg .marks { color: var(--muted); margin-left: 4px; }
.row-msg .star { color: var(--sepia); }

.list .empty, .reader .empty { padding: 30px; color: var(--muted); text-align: center; }

.reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.msg-head { padding: 14px 20px 10px; border-bottom: 1px solid var(--sepia-rule); }
.msg-head h1 { margin: 0 0 8px; color: var(--navy); font-size: 20px; font-weight: 700; }
.msg-head .meta { color: var(--muted); font-size: 13px; line-height: 1.55; }
.msg-head .meta b { color: var(--text); font-weight: 700; }

.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 20px; border-bottom: 1px solid var(--sepia-rule); }
.attachments button { font-size: 12px; }

.msg-body { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- compose ---------- */
dialog {
  border: 1px solid var(--sepia-border);
  padding: 20px 22px;
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgba(27, 54, 93, 0.25);
}

dialog::backdrop { background: rgba(27, 54, 93, 0.3); }
dialog h2 { margin: 0 0 12px; color: var(--navy); font-size: 20px; font-weight: 700; }

.compose label {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.compose label input, .compose textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--silver);
  color: var(--text);
}

.compose textarea { margin-top: 8px; resize: vertical; font-family: inherit; }
.compose input:focus, .compose textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; }

dialog .row { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- status line ---------- */
.status {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 9px 18px;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  border-bottom: 2px solid var(--sepia);
}
.status.error { background: #8B1E1E; border-bottom-color: #8B1E1E; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 24px; gap: 16px; }
  .login-logo { width: 180px; }
  .login-fractal, .login-tagline { display: none; }
  .login-panel { border-left: 0; border-top: 1px solid var(--sepia-rule); }
  .login-box { padding: 32px 24px 28px; }

  .top-logo, .account { display: none; }
  .brand { border-left: 0; padding-left: 0; min-width: 0; }
  .panes { grid-template-columns: 1fr; }
  .folders { display: none; }
  .row-msg { grid-template-columns: 20px 1fr auto; }
  .row-msg input { grid-row: 1 / 3; }
  .row-msg .date { grid-column: 3; grid-row: 1; }
  .row-msg .subject { grid-column: 2 / 4; grid-row: 2; }
  .list-pane { flex: 1; border-bottom: 0; }
  body.reading .list-pane { display: none; }
  body:not(.reading) .reader { display: none; }
}
