/* The admin panel: sidebar shell, page headers, cards, tables. Loaded after esign.css, admin pages only. */
.admin {
    --side: #0f172a;
    --side-ink: #cbd5e1;
    --side-hover: #1e293b;
    --bg: #f3f5f9;
    --line: #e6e9ef;
    --radius: 12px;
    font-size: 15px;
    background: var(--bg);
}

/* ---- Shell ---- */
.admin.has-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); color: var(--side-ink); overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #22c55e, #0f766e); color: #fff; font-size: 17px; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-size: .92rem; }
.sidebar-nav a:hover { background: var(--side-hover); color: #fff; }
.sidebar-nav a.is-active { background: #1d4ed8; color: #fff; }
.sidebar-nav svg { flex: none; opacity: .9; }
.sidebar-label { margin: 18px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #64748b; }
.sidebar-app { font-weight: 600; }
.sidebar-app.is-open { color: #fff; background: rgba(255, 255, 255, .04); }
.app-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex: none; margin: 0 5px; }
.app-dot.is-off { background: #64748b; }
.sidebar-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px 18px; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, .08); }
.sidebar-sub a { font-size: .88rem; padding: 7px 10px; }
.sidebar-add { margin-top: 8px; color: #94a3b8 !important; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #334155; color: #fff; font-weight: 700; font-size: .85rem; flex: none; }
.sidebar-email { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-out { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--side-ink); cursor: pointer; }
.sidebar-out:hover { background: var(--side-hover); color: #fff; }

.shell-main { min-width: 0; }
.admin .wrap { max-width: 1240px; margin: 0; padding: 28px 36px 48px; }
.admin .wrap.wrap-wide { max-width: none; }
.admin.is-guest .wrap { margin: 0 auto; }

/* ---- Page header ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
.page-sub { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs span { margin: 0 6px; opacity: .6; }

/* ---- Cards ---- */
.admin .card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); padding: 22px; }
.admin .card > h2:first-child, .card-head h2 { font-size: 1.02rem; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0 !important; }
.card-flush { padding: 0 !important; overflow: hidden; }
.card-flush .card-head { padding: 18px 22px 0; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.stat-label { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.stat-ok .stat-value { color: #15803d; }
.stat-warn .stat-value { color: #b45309; }
.stat-bad .stat-value { color: #b91c1c; }

/* ---- Tables ---- */
.admin table.list { font-size: .92rem; }
.admin table.list th { background: #f8fafc; font-size: .72rem; font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.admin table.list td { padding: 11px 14px; vertical-align: middle; }
.admin table.list tbody tr:hover td { background: #fafbfd; }
.admin table.list tbody tr:last-child td { border-bottom: 0; }
.admin .card:not(.card-flush) table.list { margin: 0 -8px; width: calc(100% + 16px); }
.admin table.list a { font-weight: 600; text-decoration: none; }
.admin table.list a:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }

/* ---- Pills ---- */
.admin .pill { font-weight: 600; font-size: .75rem; padding: 2px 10px; text-transform: capitalize; }

/* ---- Forms and buttons ---- */
.admin .field > span { font-size: .88rem; }
.admin input[type=text], .admin input[type=email], .admin input[type=password], .admin input[type=url], .admin input[type=number], .admin textarea, .admin select { padding: 9px 12px; border-color: #d5dbe4; font-size: .93rem; }
.admin input[type=number] { width: 100%; font: inherit; border: 1px solid #d5dbe4; border-radius: 8px; }
.admin input[type=color] { width: 56px; height: 36px; padding: 2px; border: 1px solid #d5dbe4; border-radius: 8px; background: #fff; }
.admin input:focus, .admin textarea:focus, .admin select:focus { outline: 0; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .18); }
.admin .btn { padding: 9px 16px; font-size: .92rem; border-color: #d5dbe4; box-shadow: 0 1px 1px rgba(15, 23, 42, .04); }
.admin .btn-small { padding: 5px 11px; font-size: .84rem; }
.admin .btn-primary { background: #1d4ed8; border-color: #1d4ed8; }
.admin .btn-primary:hover { background: #1e40af; filter: none; }
.admin .notice { border-radius: 10px; }
.admin dl.facts { grid-template-columns: 170px 1fr; gap: 10px 16px; font-size: .93rem; }

/* ---- Filter bar ---- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; }
.filter-bar input[type=text] { flex: 1; min-width: 240px; width: auto; }
.filter-bar select { width: auto; }

/* ---- Sign in ---- */
.admin.is-guest { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at 30% 20%, #1e293b, #0f172a 70%); }
.admin.is-guest .shell-main { width: 100%; }
.login-card { max-width: 400px; margin: 0 auto; padding: 30px !important; box-shadow: 0 20px 50px rgba(0, 0, 0, .35) !important; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
.login-card .btn-primary { width: 100%; padding: 11px; }

/* ---- Template editor inside the shell ---- */
.admin .editor-head { margin-bottom: 18px; }
.admin .editor-layout { grid-template-columns: minmax(0, 1fr) 330px; }
.admin .editor-side .card { padding: 18px; }
.admin .editor-side h2 { font-size: .98rem; margin-bottom: 8px; }
.admin .jodit-container:not(.jodit_inline) { border-color: var(--line); border-radius: var(--radius); overflow: hidden; }
.admin .jodit-toolbar__box:not(:empty) { background: #fff; border-bottom-color: var(--line); }

@media (max-width: 900px) {
    .admin.has-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-label, .sidebar-sub { display: none; }
    .admin .wrap { padding: 20px 16px 40px; }
}
.admin .editor-main .jodit-workplace { background: #fff; }

/* ---- Full width everywhere ---- */
.admin .wrap { max-width: none; padding: 24px 28px 40px; }

/* ---- Template page: editor + one panel, both filling the screen ---- */
.admin .editor-head { align-items: flex-end; margin-bottom: 14px; }
.editor-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-title-row .title-input { min-width: 320px; }
.key-label { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.admin .editor-titles input.key-input { width: 180px; margin: 0; }
.admin .editor-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: stretch; }
.admin .editor-side { position: sticky; top: 16px; height: var(--editor-h, 75vh); display: flex; flex-direction: column; padding: 0; margin: 0; overflow: hidden; }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); background: #f8fafc; flex: none; }
.side-tab { flex: 1; padding: 12px 8px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.side-tab:hover { color: var(--ink); }
.side-tab.is-active { color: #1d4ed8; border-bottom-color: #1d4ed8; background: #fff; }
.side-body { flex: 1; overflow-y: auto; padding: 18px; }
.side-body h3 { font-size: .95rem; margin: 0 0 6px; }
.side-body ul { padding-left: 18px; margin: 4px 0 10px; }
.side-rule { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.side-body table.list { margin: 0 0 8px !important; width: 100% !important; }
.admin .editor-main .jodit-container { border-radius: var(--radius); }
#preview-card { margin-top: 18px; }
@media (max-width: 1100px) {
    .admin .editor-layout { grid-template-columns: 1fr; }
    .admin .editor-side { position: static; height: auto; }
}

/* ---- Two columns that each stack their own cards ---- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.split > div > .card { margin-bottom: 20px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.split dl.facts { grid-template-columns: 1fr; gap: 2px 0; } .split dl.facts dd { margin-bottom: 10px; word-break: break-all; }
.admin table.list td > div { white-space: nowrap; line-height: 1.9; } .admin table.list td.small:first-child { white-space: nowrap; }

/* ---- Template page: signers first ---- */
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px; border-radius: 50%; background: #1d4ed8; color: #fff; font-size: .72rem; vertical-align: 1px; }
.signer-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.signer-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 30px 30px; gap: 6px; align-items: center; }
.signer-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #e8f5ec; color: #166534; font-weight: 700; font-size: .8rem; }
.signer-row input { padding: 7px 10px !important; }
.signer-state { grid-column: 2 / -1; font-size: .76rem; color: #15803d; margin-top: -2px; }
.signer-state.is-missing { color: #b45309; }
.icon-btn { width: 30px; height: 32px; border: 1px solid #d5dbe4; border-radius: 6px; background: #fff; cursor: pointer; font-size: 1rem; color: #475569; }
.icon-btn:hover:not([disabled]) { background: #f1f5f9; color: #0f172a; }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.signing-order { font-weight: 500 !important; font-size: .9rem; }
