/* ── AYONOW MAILS — shared styles ── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
  --primary:        #414d81;
  --primary-dark:   #2f3a6b;
  --primary-light:  #eef0f7;
  --primary-mid:    #6878aa;
  --primary-glow:   rgba(65,77,129,.15);
  --bg:             #f2f3f8;
  --surface:        #ffffff;
  --surface2:       #f7f8fc;
  --surface3:       #eef0f7;
  --border:         #e2e4ef;
  --border-strong:  #c8cce0;
  --text:           #1a1c2e;
  --text-2:         #555b7a;
  --text-3:         #9299b8;
  --green:          #22c55e;
  --green-bg:       #f0fdf4;
  --green-text:     #15803d;
  --red:            #ef4444;
  --red-bg:         #fef2f2;
  --red-text:       #b91c1c;
  --amber:          #f59e0b;
  --amber-bg:       #fffbeb;
  --amber-text:     #92400e;
  --font:           'Montserrat', sans-serif;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --shadow-sm:      0 1px 2px rgba(65,77,129,.06);
  --shadow:         0 2px 8px rgba(65,77,129,.08), 0 1px 2px rgba(65,77,129,.04);
  --shadow-md:      0 4px 16px rgba(65,77,129,.12), 0 2px 4px rgba(65,77,129,.06);
  --shadow-lg:      0 8px 32px rgba(65,77,129,.16), 0 4px 8px rgba(65,77,129,.08);
  --sidebar-w:      252px;
  --header-h:       72px;
  --page-pad:       28px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background:
    radial-gradient(circle at top left, rgba(104,120,170,.15), transparent 28%),
    linear-gradient(180deg, #f7f8fc 0%, #eef1f8 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ── SIDEBAR LAYOUT ── */
.app { min-height: 100vh; }

.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), transparent 22%),
    linear-gradient(180deg, #313d71 0%, #26315f 100%);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  z-index: 30;
  box-shadow: 18px 0 42px rgba(47,58,107,.14);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.sidebar-logo-text span { font-weight: 300; opacity: .6; font-size: 13px; }

.sidebar-section { padding: 16px 12px 8px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.3); padding: 0 8px; margin-bottom: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.6);
  cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--primary-mid);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 20px;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.sidebar-user:hover { background: rgba(255,255,255,.08); }
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 10px; color: rgba(255,255,255,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { color: rgba(255,255,255,.3); cursor: pointer; }
.sidebar-logout svg { width: 14px; height: 14px; }
.sidebar-logout:hover { color: rgba(255,255,255,.7); }

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid rgba(200,204,224,.75);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--page-pad);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px);
}
.topbar-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.topbar-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content {
  padding: 24px var(--page-pad) 40px;
  flex: 1;
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 20px; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; stroke: var(--primary); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-change { font-size: 11px; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--green-text); }
.stat-change.down { color: var(--red-text); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.table-wrap td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover td { background: var(--surface2); }

/* ── FORMS ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  font-size: 11px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], select, textarea {
  font-size: 13px; font-family: var(--font); color: var(--text);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea { resize: vertical; line-height: 1.6; }
.hint { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.hint a { color: var(--primary); text-decoration: underline; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; font-size: 13px; font-weight: 600;
  font-family: var(--font); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; letter-spacing: .01em;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover { background: var(--surface3); border-color: var(--border-strong); color: var(--text); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: var(--primary); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; border-color: transparent; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-danger { background: var(--red-bg); color: var(--red-text); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; color: var(--red-text); border-color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 14px; border-radius: var(--radius); }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── SENDER TYPE PILLS ── */
.sender-type {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; background: var(--primary-light); color: var(--primary-dark);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,28,46,.5);
  backdrop-filter: blur(4px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--surface2); cursor: pointer; color: var(--text-3);
  font-size: 16px; transition: background .12s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── TABS ── */
.tab-bar {
  display: flex; gap: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; width: fit-content;
}
.tab-btn {
  padding: 7px 18px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; cursor: pointer;
  background: transparent; border: none; color: var(--text-3);
  border-right: 1px solid var(--border); font-family: var(--font);
  transition: background .12s, color .12s;
}
.tab-btn:last-child { border-right: none; }
.tab-btn.active { background: var(--primary); color: #fff; }

/* ── RICH TEXT EDITOR ── */
.editor-toolbar {
  display: flex; gap: 2px; flex-wrap: wrap;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  background: var(--surface2); align-items: center;
}
.toolbar-btn {
  width: 28px; height: 28px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  font-family: var(--font); transition: background .1s, color .1s;
}
.toolbar-btn:hover { background: var(--border); color: var(--text); }
.toolbar-btn.active { background: var(--primary); color: #fff; }
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.toolbar-select {
  font-size: 12px; font-family: var(--font); color: var(--text-2);
  background: transparent; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; outline: none; cursor: pointer;
}
.editor-body {
  min-height: 200px; padding: 14px 16px; outline: none;
  font-size: 13px; line-height: 1.7; color: var(--text);
  font-family: var(--font);
}
.editor-body:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor-body table,
.sig-editor-body table,
#prev-body table,
#prev-sig table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: inherit;
}
.editor-body td,
.editor-body th,
.sig-editor-body td,
.sig-editor-body th,
#prev-body td,
#prev-body th,
#prev-sig td,
#prev-sig th {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  vertical-align: top;
}
.editor-body tr:hover td,
.sig-editor-body tr:hover td,
#prev-body tr:hover td,
#prev-sig tr:hover td {
  background: transparent;
}
.sig-editor-body img,
#prev-sig img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

/* ── PROGRESS ── */
.prog-track { height: 6px; background: var(--primary-light); border-radius: 3px; overflow: hidden; }
.prog-bar { height: 100%; width: 0; background: var(--primary); border-radius: 3px; transition: width .3s; }
.log-console {
  font-family: monospace; font-size: 11px; line-height: 2;
  background: #12141f; color: #6878aa; border-radius: var(--radius-sm);
  padding: 12px 14px; max-height: 200px; overflow-y: auto; margin-top: 10px;
}
.log-ok { color: #4ade80; }
.log-err { color: #f87171; }
.log-warn { color: #fbbf24; }
.log-info { color: #6878aa; }

/* ── MISC ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; display: block; opacity: .4; }
.empty-state p { font-size: 13px; }
.var-tag {
  font-family: monospace; font-size: 11px; padding: 2px 8px;
  background: var(--primary-light); border: 1px solid #c4cae3;
  border-radius: 4px; color: var(--primary-dark); cursor: pointer;
  font-weight: 700; transition: background .12s;
}
.var-tag:hover { background: #d8ddf0; }
.var-row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: background .15s, border-color .15s; background: var(--surface2);
}
.upload-zone:hover, .upload-zone.drag { background: var(--primary-light); border-color: var(--primary-mid); }
.upload-zone-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--primary-light); display: flex; align-items: center;
  justify-content: center; margin: 0 auto 10px;
}
.upload-zone-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── MAPPING ── */
.mapping-wrap { background: var(--primary-light); border: 1px solid #c4cae3; border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 12px; }
.mapping-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--primary-mid); margin-bottom: 10px; }
.mapping-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.mapping-row:last-child { margin-bottom: 0; }
.mapping-label { font-size: 12px; font-weight: 700; color: var(--primary-dark); width: 60px; flex-shrink: 0; }
.mapping-row select { flex: 1; font-size: 12px; padding: 6px 8px; }

/* ── SENDER CARD ── */
.sender-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: box-shadow .15s, border-color .15s;
}
.sender-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.sender-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.sender-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--primary-light); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.sender-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sender-info { flex: 1; min-width: 0; }
.sender-name { font-size: 14px; font-weight: 700; color: var(--text); }
.sender-email { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.sender-actions { display: flex; gap: 6px; }

/* ── DELAY SLIDER ── */
.delay-row { display: flex; align-items: center; gap: 14px; }
input[type=range] {
  flex: 1; -webkit-appearance: none; height: 4px;
  background: var(--border); border-radius: 2px; border: none; padding: 0; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--primary);
}
.delay-val { font-size: 13px; font-weight: 700; color: var(--primary); min-width: 30px; text-align: right; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at top, rgba(255,255,255,.12), transparent 24%),
    linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; padding: 40px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; margin: 0 auto 14px;
  font-size: 24px; font-weight: 700; color: #fff;
}
.login-logo-text { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo-sub { font-size: 13px; color: var(--text-3); margin-top: 4px; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 920px) {
  :root {
    --sidebar-w: 100%;
    --header-h: auto;
    --page-pad: 18px;
  }
  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
    box-shadow: none;
  }
  .main {
    margin-left: 0;
    width: 100%;
  }
  .topbar {
    position: static;
    padding: 18px var(--page-pad);
  }
  .content {
    padding-top: 18px;
  }
  .grid2, .grid3, .stat-grid {
    grid-template-columns: 1fr;
  }
}
