/* QWS Licensing - shared site styles */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #dde2ea;
    --text: #1d2433;
    --muted: #5f6b7e;
    --header-bg: #17223b;
    --header-text: #c8d1e3;
    --accent: #1f5fbf;
    --accent-hover: #184c99;
    --accent-soft: #e8f0fc;
    --danger: #b42318;
    --danger-bg: #fdecea;
    --success: #146c43;
    --success-bg: #e7f5ee;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); }

/* ---------- Site header ---------- */

.site-header { background: var(--header-bg); color: #fff; }
.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 16px;
}
.brand-name { font-weight: 600; font-size: 16px; line-height: 1.1; }
.brand-sub { display: block; font-size: 11px; color: var(--header-text); font-weight: normal; }

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.site-nav a {
    color: var(--header-text);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
}
.site-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.site-nav a.active { background: rgba(255,255,255,.16); color: #fff; }

.site-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--header-text); }
.site-user a { color: var(--header-text); }
.site-user a:hover { color: #fff; }

/* ---------- Section sub-navigation (activation console) ---------- */

.subnav { background: var(--surface); border-bottom: 1px solid var(--border); }
.subnav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 48px;
}
.subnav-tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.subnav-tabs a {
    color: var(--muted);
    text-decoration: none;
    padding: 12px 14px;
    border-bottom: 2px solid transparent;
    font-weight: 600;
}
.subnav-tabs a:hover { color: var(--text); }
.subnav-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.subnav-tools { font-size: 13px; color: var(--muted); }
.subnav-tools select { font-size: 13px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; }

/* ---------- Page layout ---------- */

main.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

.site-footer { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; color: var(--muted); font-size: 12px; }

/* Pages with wide tables (Customers) use more of the screen - header and tabs too, so their edges line up */
body:has(.page-wide) .site-header-inner,
body:has(.page-wide) .subnav-inner,
body:has(.page-wide) main.page,
body:has(.page-wide) .site-footer { max-width: 1600px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.card h2 { font-size: 18px; font-weight: 600; margin: 0 0 16px; }
/* Links to a page's sections, and each section's way back up */
.section-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 12px; font-size: 13px; }
.section-top { font-size: 12px; margin: -6px 0 8px; }
.section-top a { color: var(--muted); text-decoration: none; }
.section-top a:hover { color: var(--accent); text-decoration: underline; }
[id] { scroll-margin-top: 12px; }

.card h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 16px; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .field .label { font-weight: 600; font-size: 13px; }
.field .required { color: var(--danger); }
.field input:disabled { background: var(--bg); color: var(--muted); }
.field-row { display: flex; gap: 8px; }
.field-row select { flex: 0 0 auto; width: auto; }
.hint { color: var(--muted); font-size: 12px; }
code, .mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], textarea, select.input, .field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
.field-row select { width: auto; }
textarea { font-family: Consolas, "Courier New", monospace; font-size: 13px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=file] { font: inherit; }

/* A text box with an x button in its top-right corner that clears it (shown only when there's text) */
.clearable { position: relative; }
.clearable textarea, .clearable input { padding-right: 34px; }
.clear-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 24px;
    cursor: pointer;
}
.clearable input ~ .clear-btn { top: 50%; transform: translateY(-50%); }
.clear-btn:hover { background: var(--bg); color: var(--text); }
.clear-btn[hidden] { display: none; }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; }
.check input { margin-top: 3px; }
.check label { font-weight: 600; }
.check .hint { display: block; font-weight: normal; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.btn, input[type=submit].btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 9px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn.secondary, input[type=submit].btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #eef1f6; }
.btn.danger, input[type=submit].btn.danger { background: #fff; color: var(--danger); border: 1px solid #f1b8b2; padding: 5px 12px; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.block { width: 100%; text-align: center; }
.btn.small, input[type=submit].btn.small { padding: 3px 10px; font-size: 12px; font-weight: 600; }

/* A table row's links and buttons, spaced apart */
.row-actions { display: inline-flex; align-items: center; gap: 8px; }
.row-actions > a { margin-right: 8px; }

/* ---------- Messages & status ---------- */

.message { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; }
.message.error { background: var(--danger-bg); color: var(--danger); }
.message.success { background: var(--success-bg); color: var(--success); }

/* Console messages stay in view at the top of the window while the page is scrolled */
.message.pinned {
    position: sticky;
    top: 8px;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid currentColor;
    box-shadow: 0 4px 14px rgba(23,34,59,.15);
}
.message.pinned > span { flex: 1; }
.message-close {
    background: none;
    border: 0;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: .7;
}
.message-close:hover { opacity: 1; }
.message:not(.pinned) .message-close { display: none; }
.status-text:empty { display: none; }
.status-text { display: inline-block; font-weight: 600; }

.steps { counter-reset: step; }
.card.step { position: relative; padding-left: 60px; }
.step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 20px;
    top: 18px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    display: grid;
    place-items: center;
    font-size: 13px;
}

/* ---------- Data display ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
table.data td.mono { word-break: break-all; }
.empty { color: var(--muted); padding: 12px 0; }
table.data.compact th, table.data.compact td { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
table.data.compact td.wrap { white-space: normal; min-width: 180px; }
table.data th.num, table.data td.num { text-align: right; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.success { background: var(--success-bg); color: var(--success); }

dl.summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; font-weight: 600; }.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Home tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
/* Five tiles: one even row when there's room, rather than four and a straggler */
@media (min-width: 900px) { .tiles.tiles-5 { grid-template-columns: repeat(5, 1fr); } }
a.tile {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}
a.tile:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(23,34,59,.08); }
.tile-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.tile-text { color: var(--muted); font-size: 13px; }
.db-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.db-card .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.db-card .db-name { font-size: 20px; font-weight: 600; font-family: Consolas, "Courier New", monospace; }
.db-card .badge { font-size: 13px; padding: 4px 12px; }
.badge.warning { background: #fff4e5; color: #9a5b00; }
.badge.muted { background: #eef1f6; color: var(--muted); }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 24px 0 10px; }

/* ---------- Usage reporting ---------- */

.report-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .report-layout { grid-template-columns: 1fr; } }
.report-nav h3 { margin-top: 16px; }
.report-nav h3:first-child { margin-top: 0; }
.report-nav a { display: block; padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.report-nav a:hover { background: #eef1f6; }
.report-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chart-wrap { overflow-x: auto; }
.chart-wrap img { max-width: 100%; height: auto; }

.date-filters { display: flex; gap: 20px; flex-wrap: wrap; }
table.calendar { border-collapse: collapse; border: 1px solid var(--border) !important; background: #fff; font-size: 12px; margin-top: 6px; }
table.calendar td, table.calendar th { padding: 4px 7px; text-align: center; }
table.calendar a { color: var(--text) !important; text-decoration: none; }
table.calendar > tbody > tr:first-child > td, table.calendar .cal-title { background: var(--bg) !important; border: 0 !important; font-weight: 600; }
table.calendar .cal-title a { color: var(--accent) !important; }
table.calendar .cal-dayheader { color: var(--muted); font-weight: 600; }
table.calendar .cal-other a { color: #b3bccb !important; }
table.calendar .cal-today { outline: 1px solid var(--accent); }
table.calendar .cal-selected { background: var(--accent) !important; }
table.calendar .cal-selected a { color: #fff !important; }

/* ---------- Login ---------- */

body.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 4px 24px rgba(23,34,59,.06);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .subtitle { margin-bottom: 24px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .actions { margin-top: 22px; }

/* Popups (<dialog>): Zoho notes, quote descriptions */
.popup-dialog { width: min(760px, 92vw); max-height: 82vh; overflow-x: hidden; border: 1px solid var(--border); border-radius: 12px; padding: 20px; color: var(--text); background: var(--surface); }
.popup-dialog::backdrop { background: rgba(23, 34, 59, .45); }
.popup-dialog .note { border-top: 1px solid var(--border); padding: 12px 0; }
.popup-dialog .popup-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
