/* Krishna Mail — admin stylesheet.
 *
 * Hand-written and dependency-free. A CSS framework would be one more thing to
 * update and one more thing to override; this is a few hundred lines that can be
 * read in one sitting and does everything the panel needs.
 *
 * Dark by default: this is an operations tool that people leave open, and the
 * mail-specific statuses (sent / bounced / suppressed) read better against a dark
 * ground than pastel pills on white.
 */

:root {
    --bg:        #12151c;
    --panel:     #191d26;
    --panel-2:   #1f2431;
    --line:      #2a3040;
    --text:      #e6e9ef;
    --muted:     #98a1b3;
    --faint:     #6b7488;
    --accent:    #6ea8fe;
    --accent-dim:#2c4a7c;
    --green:     #4ade80;
    --red:       #f87171;
    --amber:     #fbbf24;
    --blue:      #60a5fa;

    --radius: 8px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- shell -- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex: 0 0 220px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { padding: 22px 20px 18px; }
.brand a {
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.brand a span { color: var(--accent); }

.sidebar nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; flex: 1; }
.sidebar nav a {
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidebar nav a.on { background: var(--accent-dim); color: #fff; font-weight: 500; }

.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--line); }
.sidebar-foot .who { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.sidebar-foot .modes {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px; padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.sidebar-foot .modes a { font-size: 12px; color: var(--faint); }
.sidebar-foot .modes a:hover { color: var(--accent); }

.linkish {
    background: none; border: 0; padding: 0;
    color: var(--faint); font: inherit; font-size: 13px; cursor: pointer;
}
.linkish:hover { color: var(--accent); text-decoration: underline; }

.main { flex: 1; padding: 28px 34px 60px; max-width: 1400px; }

/* ---------------------------------------------------------- simulation -- */

/* The bar that says a site is sending mail somewhere other than to customers.
 * Amber on a panel that is otherwise dark and quiet, because this is the one state on
 * these screens that is doing something irreversible while looking like production. */
.simbar {
    border: 1px solid; border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 22px; font-size: 14px;
}
.simbar-on { background: #2e2611; border-color: #6b5320; color: #f5dda6; }
.simbar-quiet {
    background: var(--panel); border-color: var(--line); color: var(--muted);
    display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 13px;
}
.simbar-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.simbar-on .pill-amber { background: #4a3a12; color: #ffd76e; }
.simbar-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    padding: 9px 0 0; border-top: 1px solid #4a3d1c;
}
.simbar-row code { background: #3d3215; color: #ffe9b0; }
.simbar-on .hint { color: #c3a86a; }
.simbar-on .hint a { color: #ffd76e; }
.simbar-on .btn { border-color: #6b5320; }

/* ------------------------------------------------------------ page head -- */

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; align-items: center; }
.inline { display: inline; }

/* --------------------------------------------------------------- atoms -- */

.btn {
    display: inline-block;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: #262c3a; text-decoration: none; }
.btn-primary { background: var(--accent-dim); border-color: #3d6099; color: #fff; }
.btn-primary:hover { background: #365a92; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: #3a2226; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.flash {
    padding: 11px 14px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px;
    border: 1px solid;
}
.flash-success { background: #16301f; border-color: #2a5936; color: #b6f0c8; }
.flash-error   { background: #33191d; border-color: #6b2f36; color: #f6bcc2; }
.flash-info    { background: #16283d; border-color: #2c4a7c; color: #bcd8ff; }

.pill {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill-grey  { background: #2a3040; color: #b8c0d0; }
.pill-green { background: #16381f; color: var(--green); }
.pill-red   { background: #3a1d21; color: var(--red); }
.pill-amber { background: #3a2f13; color: var(--amber); }
.pill-blue  { background: #172a45; color: var(--blue); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card h2 {
    margin: 0 0 14px; font-size: 15px; font-weight: 600;
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 3px; }
.stat.warn .n { color: var(--amber); }
.stat.bad  .n { color: var(--red); }

/* --------------------------------------------------------------- table -- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; padding: 9px 12px; color: var(--faint);
    font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--line);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 34px; text-align: center; color: var(--faint); }

/* ---------------------------------------------------------------- forms -- */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.45; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=time], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 11px;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px rgba(110,168,254,0.12);
}
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; }
textarea.code { min-height: 280px; }

.field { margin-bottom: 16px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check label { margin: 0; color: var(--text); font-size: 14px; }

code, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; color: #cbd5e5; }

pre.raw {
    background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
    padding: 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.55;
    max-height: 520px; white-space: pre-wrap; word-break: break-word;
}

/* --------------------------------------------------------------- login -- */

.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login {
    width: 100%; max-width: 360px; background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; padding: 28px;
}
.login h1 { margin: 0 0 6px; font-size: 20px; }
.login .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login .btn { width: 100%; }

/* ------------------------------------------------------------- preview -- */

.preview-frame {
    width: 100%; height: 560px; border: 1px solid var(--line);
    border-radius: 6px; background: #fff;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a {
    padding: 8px 14px; color: var(--muted); font-size: 14px;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.var-list { font-size: 13px; }
.var-list dt { font-family: var(--mono); color: #cbd5e5; margin-top: 9px; }
.var-list dd { margin: 2px 0 0; color: var(--faint); font-size: 12.5px; }

.timeline { font-size: 13.5px; }
.timeline .item { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.timeline .item:last-child { border-bottom: 0; }
.timeline .when { color: var(--faint); flex: 0 0 92px; font-size: 12.5px; }

/* ---------------------------------------------------------------- rich editor --
 *
 * The toolbar and the editable area. Sized so the editable region is roughly the shape of
 * an email: a narrow column, because a body typed across a 1400px window looks nothing like
 * what arrives in an inbox and the person composing it never finds that out until it is
 * sent.
 */
.km-editor { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }

.km-bar {
    display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
    padding: 8px; border-bottom: 1px solid var(--line); background: #f6f7f8;
}

.km-tool {
    font: inherit; font-size: 12px; line-height: 1.4;
    padding: 5px 9px; min-width: 30px;
    border: 1px solid var(--line); border-radius: 5px;
    background: #fff; color: var(--text); cursor: pointer;
}
.km-tool:hover { border-color: var(--accent); color: var(--accent); }
.km-tool.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.km-area {
    min-height: 320px; max-height: 620px; overflow-y: auto;
    padding: 18px 20px; background: #fff;
    font-size: 15px; line-height: 1.6;
    /* Left-aligned and full width rather than centred in a fake mailbox: the person is
       writing content, and the layout around it is the template's job, shown in Preview. */
}
.km-area:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.km-area p { margin: 0 0 16px 0; }
.km-area img { max-width: 100%; height: auto; }

/* A template token, made atomic. The tint is not decoration: it tells the writer that this
   is machinery rather than text, and that clicking it will select all of it. */
.km-token {
    display: inline-block;
    padding: 1px 5px; margin: 0 1px;
    border-radius: 4px;
    background: #eef4fc; border: 1px solid #cfe0f5;
    color: #1a5fb4; font-family: ui-monospace, monospace; font-size: 12px;
    cursor: default; white-space: nowrap;
}

.km-source textarea {
    width: 100%; min-height: 320px; border: 0; border-radius: 0;
    font-family: ui-monospace, monospace; font-size: 13px;
    padding: 14px; resize: vertical;
}
.km-source textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- The stepped creation flow ------------------------------------------------
   Steps are a list, not a progress bar, because the useful question is "which one am I on
   and how do I get back" rather than a percentage. A finished step is a link; the ones
   ahead are not, so nothing can be skipped to the end and sent from there. */
.wizard-strip {
    display: flex; flex-wrap: wrap; gap: 8px;
    list-style: none; margin: 0 0 18px 0; padding: 0;
    counter-reset: none;
}
.wizard-step { flex: 0 1 auto; }
.wizard-step > span, .wizard-step > a {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px 7px 10px;
    border: 1px solid var(--line); border-radius: 999px;
    color: var(--muted); text-decoration: none; font-size: 13px;
    white-space: nowrap;
}
.wizard-step > a:hover { border-color: var(--accent); color: var(--text); }
.wizard-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--panel-2); color: var(--muted);
    font-size: 12px; font-weight: 600;
}
.wizard-step-done > a, .wizard-step-done > span { color: var(--faint); }
.wizard-step-done .wizard-number { background: transparent; color: var(--green); }
.wizard-step-current > span {
    border-color: var(--accent); color: var(--text);
    background: var(--panel-2); font-weight: 600;
}
.wizard-step-current .wizard-number { background: var(--accent); color: #10131a; }
.wizard-step-todo > span { opacity: .55; }

/* The row of buttons under a step. `flex-direction: row-reverse` in the markup's order
   would put Back on the right; instead the primary action is last and pushed over, so a
   form with no primary action at all still reads left to right. */
.wizard-nav { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.wizard-nav .wizard-spacer { flex: 1 1 auto; }
.wizard-nav .hint { margin: 0; }
