/* ========================================================================
   2maXMail — Editorial Office Design System
   A refined, paper-and-ink aesthetic. Serif display, precise sans UI.
   ======================================================================== */

@import url('https://fonts.bunny.net/css?family=fraunces:400,400i,500,500i,600,700|manrope:300,400,500,600,700|jetbrains-mono:400,500');

:root {
  /* — Ink & paper — */
  --ink:         #1A1814;
  --ink-soft:    #2F2C26;
  --muted:       #736E65;
  --muted-soft:  #A8A296;

  /* — Surfaces — */
  --paper:       #F6F2EB;
  --paper-deep:  #EEE9DF;
  --surface:     #FFFFFF;
  --surface-alt: #FBF9F4;

  /* — Lines & dividers — */
  --line:        #E5E0D2;
  --line-soft:   #EEEADD;
  --line-strong: #C9C3B1;

  /* — Accent: brand orange (matches logo gradient) — */
  --accent:         #F07C3D;
  --accent-deep:    #C85E1F;
  --accent-soft:    #FCE7D6;
  --accent-hover:   #D86825;

  /* — Signal: warm amber (flags, stars, OOO) — */
  --signal:         #F4A020;
  --signal-soft:    #FDEED1;

  /* — Status — */
  --success: #2F7A4E;
  --warning: #B37A0E;
  --danger:  #9F2A2A;
  --info:    #2A5C8C;

  /* — Type — */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-ui:      'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* — Geometry — */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* — Motion — */
  --ease:      cubic-bezier(.22,.61,.36,1);
  --ease-out:  cubic-bezier(.16,1,.3,1);

  /* — Shadows: paper-like, not synthetic — */
  --shadow-sm: 0 1px 2px rgba(64,31,15,.05), 0 0 0 1px rgba(64,31,15,.04);
  --shadow-md: 0 2px 4px rgba(64,31,15,.06), 0 8px 24px rgba(64,31,15,.06);
  --shadow-lg: 0 10px 40px rgba(64,31,15,.09), 0 2px 8px rgba(64,31,15,.04);
  --shadow-pop: 0 20px 60px rgba(64,31,15,.15), 0 4px 16px rgba(64,31,15,.08);
}

/* ——— Reset & baseline ——— */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: 'ss01' on, 'cv11' on;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ——— Grain texture overlay: paper feel ——— */
.grain::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}

/* ——— Typography utilities ——— */
.font-display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; }
.font-mono    { font-family: var(--font-mono); }

.display-1 { font-family: var(--font-display); font-size: clamp(48px, 7vw, 96px); line-height: 1; letter-spacing: -.02em; }
.display-2 { font-family: var(--font-display); font-size: clamp(32px, 4vw, 56px); line-height: 1.02; letter-spacing: -.015em; }
.display-3 { font-family: var(--font-display); font-size: clamp(24px, 2.5vw, 32px); line-height: 1.1; letter-spacing: -.01em; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 500; font-size: 13.5px;
  letter-spacing: -.005em;
  transition: all .18s var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn svg { width: 16px; height: 16px; stroke-width: 1.5; flex: none; }

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); color: #fff; }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--paper-deep); }

.btn-outline { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink); background: var(--paper-deep); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { width: 34px; padding: 0; }

/* ——— Inputs ——— */
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field-label {
  font-size: 12px; font-weight: 500;
  color: var(--muted); letter-spacing: .02em;
}
.input, .select, .textarea {
  width: 100%;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  color: var(--ink);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-soft); }
.input:focus, .select:focus, .textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-soft); }

/* Ghost input (no chrome) */
.input-ghost {
  border: 0; background: transparent; padding: 0;
  height: auto;
}
.input-ghost:focus { box-shadow: none; }

/* ——— Chips, Tags ——— */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  font-size: 11.5px; font-weight: 500;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.chip-accent { background: var(--accent-soft); color: var(--accent-deep); }
.chip-signal { background: var(--signal-soft); color: var(--signal); }
.chip-danger { background: #F7E2E2; color: var(--danger); }
.chip-warning { background: #F7EBD0; color: var(--warning); }
.chip-info   { background: #DCE8F4; color: var(--info); }

/* ——— Cards / Panels ——— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.card-padded { padding: 24px; }
.card-sep { border-top: 1px solid var(--line-soft); }

/* ——— Scrollbar ——— */
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb {
  background: transparent; border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
.scroll:hover::-webkit-scrollbar-thumb { background: var(--line-strong); background-clip: padding-box; border: 3px solid transparent; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); background-clip: padding-box; border: 3px solid transparent; }

/* ——— Avatars ——— */
.avatar {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  letter-spacing: -.02em;
  user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 22px; }

/* Deterministic avatar tints (paper-like) */
.avatar[data-tint="0"] { background: #ECE0D1; color: #6B4E26; }
.avatar[data-tint="1"] { background: #D9E7DA; color: #2A5C3A; }
.avatar[data-tint="2"] { background: #E0D8E8; color: #4F3B70; }
.avatar[data-tint="3"] { background: #E5DFD1; color: #6B5A26; }
.avatar[data-tint="4"] { background: #DCE4EE; color: #2F4E74; }
.avatar[data-tint="5"] { background: #EFDCD6; color: #8A3D2A; }
.avatar[data-tint="6"] { background: #D7E4E4; color: #2F5F5F; }
.avatar[data-tint="7"] { background: #EADFD1; color: #6B4820; }

/* ——— Rule / hairline ——— */
.rule { height: 1px; background: var(--line); width: 100%; }
.rule-soft { background: var(--line-soft); }

/* ——— Toast ——— */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-pop);
  z-index: 9999;
  animation: toast-in .3s var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ——— Dialog / Modal ——— */
.dlg-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,24,20,.32);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .18s var(--ease-out);
}
.dlg {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: pop .24s var(--ease-out);
}
.dlg-lg { max-width: 720px; }
.dlg-xl { max-width: 1040px; }
.dlg-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--line-soft); }
.dlg-body { padding: 20px 24px; overflow-y: auto; }
.dlg-footer { padding: 14px 24px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ——— Tables ——— */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  padding: 12px 16px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
.tbl tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: var(--surface-alt); }
.tbl tbody tr:last-child td { border-bottom: 0; }

/* ——— Loading spinner ——— */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— Text selection ——— */
::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* ——— Focus ring for keyboard users ——— */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:focus:not(:focus-visible) { outline: none; }
