/* Admin panels (company admin + platform admin) */
:root {
    --p: #1f5fbf;
    --ink: #18202c;
    --muted: #667085;
    --line: #e4e7ec;
    --bg: #f3f5f9;
    --side: #101828;
    --danger: #c0362c;
    --ok: #12804a;
    --radius: 12px;
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
    font-size: 15px; line-height: 1.55;
}
a { color: var(--p); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.center { text-align: center; }
.right { display: flex; justify-content: flex-end; margin-bottom: 12px; }
code { background: #eef1f6; padding: 2px 6px; border-radius: 6px; font-size: .85em; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--p); border-color: var(--p); color: #fff; }
.btn-danger { background: #fff; border-color: #f1c4bf; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-link { background: none; border: 0; color: inherit; }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

/* Cards / alerts */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.alert-success { background: #e8f6ee; border: 1px solid #b7e2c8; color: #0f5e36; }
.alert-error { background: #fdecea; border: 1px solid #f4c3bd; color: #9b2a20; }
.alert-info { background: #eaf2fd; border: 1px solid #c2d8f7; color: #1b4a8a; }

/* Auth / centered pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head h1 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-logo { height: 64px; width: auto; max-width: 200px; object-fit: contain; margin: 0 auto 12px; display: block; }
.big-code { font-size: 2.4rem; font-weight: 800; margin: 0; }

/* Forms */
.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=number],
.field textarea, .field select, .table input[type=text], .table input[type=number] {
    width: 100%; padding: 9px 12px; border: 1px solid #cfd5df; border-radius: 9px; font: inherit; background: #fff;
}
.field textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(31, 95, 191, .18); border-color: var(--p); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400 !important; }
.form-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-grid .grow { flex: 1 1 220px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid #cfd5df; border-radius: 8px; background: #fff; }
.image-field { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.thumb-wrap {
    width: 180px; height: 110px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden;
    background: repeating-conic-gradient(#f1f3f7 0 25%, #fff 0 50%) 50% / 16px 16px;
}
.thumb { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-controls { display: grid; gap: 8px; min-width: 0; }
.narrow-card { max-width: 560px; }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.theme-card { position: relative; display: grid; gap: 0; align-content: start; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; font-weight: 400 !important; transition: border-color .15s ease, box-shadow .15s ease; }
.theme-card:hover { border-color: #b9c4d4; }
.theme-card input { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; accent-color: var(--p); }
.theme-card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-bottom: 1px solid var(--line); background: #f3f5f9; }
.theme-card-text { display: grid; gap: 2px; padding: 10px 12px 12px; }
.theme-card-text small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.theme-card:has(input:checked) { border-color: var(--p); box-shadow: 0 0 0 3px rgba(31, 95, 191, .18); }
.theme-card:has(input:focus-visible) { outline: 3px solid rgba(31, 95, 191, .35); }

.preset-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.preset-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 400 !important; }
.preset-card:hover { border-color: #b9c4d4; }
.preset-card input { position: absolute; opacity: 0; pointer-events: none; }
.preset-card img { width: 40px; height: 40px; flex: none; }
.preset-card span { display: grid; line-height: 1.25; font-size: .9rem; }
.preset-card small { color: var(--muted); font-size: .78rem; }
.preset-card:has(input:checked) { border-color: var(--p); box-shadow: 0 0 0 3px rgba(31, 95, 191, .18); background: #f5f8ff; }
.preset-card:has(input:focus-visible) { outline: 3px solid rgba(31, 95, 191, .35); }

.partners { display: grid; gap: 10px; }
.partner-row {
    display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: 10px; align-items: center;
    padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
}
.partner-row input[type=text] { width: 100%; padding: 9px 12px; border: 1px solid #cfd5df; border-radius: 9px; font: inherit; background: #fff; }
.partner-cats { display: flex; gap: 12px; flex-wrap: wrap; font-size: .88rem; }
@media (max-width: 1100px) {
    .partner-row { grid-template-columns: 1fr 1fr; }
    .partner-cats { grid-column: 1 / 2; }
}
@media (max-width: 600px) {
    .partner-row { grid-template-columns: 1fr; }
    .partner-cats { grid-column: auto; }
}
.input-year { width: 90px !important; }
input[type=file] { width: 100%; max-width: 100%; font: inherit; font-size: .88rem; }
.table .input-title { min-width: 200px; }
.table td.actions { justify-content: flex-end; }

/* Panel layout */
.panel { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px; flex: none; background: var(--side); color: #cfd6e2; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 9px; padding: 3px; flex: none; }
.sidebar-brand strong { display: block; color: #fff; font-size: .98rem; line-height: 1.25; }
.sidebar-brand small { color: #8d99ad; }
.sidebar-nav { display: grid; gap: 2px; padding: 14px 10px; }
.sidebar-nav a {
    display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 8px;
    color: #cfd6e2; text-decoration: none; font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.active { background: var(--p); color: #fff; }
.badge { font-style: normal; background: #f04438; color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 14px; display: grid; gap: 8px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-foot .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .2); }
.sidebar-foot .btn-link { color: #8d99ad; }
.panel-main { flex: 1; min-width: 0; }
.panel-top { display: flex; align-items: center; gap: 12px; padding: 20px 28px 0; }
.panel-top h1 { font-size: 1.45rem; margin: 0; }
.sidebar-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }
.panel-content { padding: 20px 28px 40px; max-width: 1180px; }
.sidebar-backdrop { display: none; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { text-decoration: none; color: var(--ink); margin: 0; display: grid; gap: 4px; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat strong { font-size: 2rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin: 0; }
.quick-links { margin: 0 0 14px; padding-left: 18px; display: grid; gap: 6px; }
.msg-mini { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.msg-mini li { display: grid; border-left: 3px solid transparent; padding-left: 10px; }
.msg-mini li.unread { border-left-color: var(--p); }
.msg-mini span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-mini small { color: var(--muted); font-size: .78rem; }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: .9rem; }
.tabs a.active { background: var(--p); border-color: var(--p); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.status.on { background: #e8f6ee; color: var(--ok); }
.status.off { background: #f2f4f7; color: var(--muted); }

/* Messages */
.msg-list { display: grid; gap: 10px; }
.msg { margin: 0; padding: 0; }
.msg summary { display: grid; grid-template-columns: 1.2fr 2fr auto; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; align-items: center; }
.msg summary::-webkit-details-marker { display: none; }
.msg.unread summary { font-weight: 700; border-left: 4px solid var(--p); border-radius: var(--radius) 0 0 var(--radius); }
.msg-from small { color: var(--muted); font-weight: 400; }
.msg-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-date { color: var(--muted); font-size: .85rem; font-weight: 400; }
.msg-body { padding: 0 18px 16px; border-top: 1px solid var(--line); }

/* Platform result log */
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.log li { padding: 10px 12px; border-radius: 8px; background: #f6f7f9; }
.log li.ok { background: #e8f6ee; color: #0f5e36; }
.log li.error { background: #fdecea; color: #9b2a20; }
.log li.skip { background: #fff7e6; color: #8a5a00; }
.secret { font-family: ui-monospace, Consolas, monospace; background: #101828; color: #fff; padding: 3px 8px; border-radius: 6px; user-select: all; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-all; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }
    .sidebar-toggle { display: inline-block; }
    .panel-top { padding: 16px 16px 0; }
    .panel-content { padding: 16px 16px 32px; }
    .stats, .grid-2 { grid-template-columns: 1fr; }
    .msg summary { grid-template-columns: 1fr; gap: 2px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dd { margin-bottom: 8px; }
}
