:root {
    --bg: #0f1115;
    --card-bg: #1a1d24;
    --border: #2a2e38;
    --text: #e6e6e6;
    --muted: #9aa0ab;
    --accent: #4c8bf5;
    --green: #3ecf8e;
    --red: #f26d6d;
}
* { box-sizing: border-box; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    margin: 0;
    padding: 40px 40px 40px 40px;
    font-size: 17px;
    line-height: 1.55;
}
/* Left sidebar - fixed, full height, present on every page (logged in or not). body gets a
   matching left offset below so page content never sits under it. */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: #16181f;
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar .brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3;
    padding: 0 24px 24px;
    display: block;
}
.brand-mark { display: block; width: 28px; height: 28px; margin-bottom: 10px; }
.sidebar-links { display: flex; flex-direction: column; }
.sidebar-links a.nav-cta { color: #fff; }
.sidebar-links a {
    color: var(--muted);
    text-decoration: none;
    padding: 12px 24px;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}
.sidebar-links .nav-logout {
    width: 100%;
    text-align: left;
    background: none;
    color: var(--muted);
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
}
.sidebar-links .nav-logout:hover { color: var(--text); background: rgba(255,255,255,0.03); opacity: 1; }
.sidebar-links a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar-links a.active { color: var(--text); border-left-color: var(--accent); background: rgba(255,255,255,0.04); }

body { padding-left: 240px; } /* 200px sidebar + 40px page padding, in one consistent offset */
body.no-sidebar { padding-left: 40px; }

/* Deliberately NO background/border/box here - page content sits directly on the page
   background, matching the reference screenshots (only small distinct sub-elements, like the
   table below, get their own panel styling - not the whole page). */
.card {
    max-width: 640px;
    margin: 0;
    padding: 0;
}
.card.wide { max-width: 1200px; }
h1 { margin-top: 0; font-size: 1.4rem; }
a { color: var(--accent); }
label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 0.9rem; }
input[type="email"], input[type="text"] {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 1rem;
}
button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 18px;
    font-size: 0.95rem;
    cursor: pointer;
}
button:hover { opacity: 0.9; }
table { width: 100%; border-collapse: collapse; margin: 16px 0; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); font-size: 0.85rem; }
.notice { color: var(--green); }
.error { color: var(--red); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input[type="number"], input[type="datetime-local"], select {
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
}
/* One-row edit forms inside table cells (customer.php): never wrap, compact fields. */
td .inline-form { flex-wrap: nowrap; gap: 5px; }
td .inline-form input[type="number"] { width: 60px; flex: none; padding: 6px 4px; }
td .inline-form input[type="text"] { width: 160px; flex: none; margin: 0; padding: 6px 8px; font-size: 0.9rem; }
td .inline-form input[type="datetime-local"] { width: 150px; flex: none; padding: 6px 4px; }
td .inline-form select { flex: none; }
td .inline-form label { display: inline-flex; align-items: center; gap: 3px; margin: 0; white-space: nowrap; font-size: 0.75rem; }
td .inline-form button { padding: 6px 10px; white-space: nowrap; }
.section { margin-top: 36px; }

/* Tab bar (licenses.php) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 22px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs a { padding: 12px 16px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.95rem; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,0.08); font-size: 0.75rem; }
.tabs a.has-items .count { background: rgba(230,180,80,0.2); color: #e6b450; }
.test-tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(230,180,80,0.14); color: #e6b450; border: 1px solid rgba(230,180,80,0.4); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }

/* Buy page */
.buy-lead { font-size: 1.1rem; line-height: 1.6; margin: 0 0 8px; }
.buy-lead strong { color: #fff; }
label.field-title { color: var(--muted); font-size: 0.95rem; margin: 18px 0 8px; }
.field-title { color: var(--muted); font-size: 0.95rem; margin: 18px 0 8px; }
.currency-options { display: grid; gap: 10px; margin-bottom: 24px; }
.currency-options label { display: flex; align-items: center; gap: 12px; margin: 0; padding: 14px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 1.05rem; cursor: pointer; }
.currency-options label:has(input:checked) { border-color: var(--accent); background: rgba(76, 139, 245, 0.10); }
.currency-options input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.price-line { font-size: 1.15rem; margin: 6px 0 22px; }
.pay-buttons { display: flex; flex-direction: column; gap: 12px; }
.pay-note { margin: 18px 0 0; font-size: 0.95rem; line-height: 1.5; }
.pay-note strong { color: var(--text); }
.btn-pay { width: 100%; padding: 15px 20px; font-size: 1.05rem; font-weight: 600; border-radius: 10px; min-height: 52px; }
a.row-link { color: var(--accent); text-decoration: none; }
a.row-link:hover { text-decoration: underline; }

/* Sales page frame (index.php) - placeholder layout, content/styling to be filled in later */
.hero { text-align: center; padding: 60px 16px 40px; }
.hero h1 { font-size: 2.2rem; margin-bottom: 8px; }
.tagline { color: var(--muted); margin-bottom: 24px; }
.cta {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 600;
}
.cta:hover { opacity: 0.9; }
.features, .pricing { max-width: 800px; margin: 0 auto; padding: 24px 16px; text-align: center; }
footer { text-align: center; padding: 24px 16px 60px; color: var(--muted); }

/* Crypto payment page (crypto-pay.php) */
.copy-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 6px; }
.copy-row code { flex: 1; min-width: 0; padding: 14px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; font-size: 1.05rem; word-break: break-all; color: var(--text); display: flex; align-items: center; }
.copy-btn { flex: none; }
.pay-timer { margin: 20px 0 6px; font-size: 1.05rem; }
.warn-list { margin: 14px 0 18px; padding-left: 22px; }
.warn-list li { margin-bottom: 8px; }

/* ---- Phone layout (max 640px) - deliberately LAST in this file so it wins over the base rules above.
   The sidebar becomes a top bar and the page content gets an even left/right gutter. ---- */
@media (max-width: 640px) {
    /* Phone layout: the sidebar becomes a top bar, the page content gets an even left/right gutter. */
    /* Header = the same top bar as the home page: logo + name left, "Log in" + blue "Buy now" right. */
    .sidebar { position: sticky; top: 0; width: 100%; height: 58px; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 18px;
               background: rgba(15,17,21,0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-right: 0; border-bottom: 1px solid rgba(38,44,57,0.7); }
    .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0; font-weight: 700; font-size: 1rem; line-height: 1.15; letter-spacing: -0.01em; }
    .brand-mark { width: 26px; height: 26px; margin: 0; flex: none; }
    .sidebar .brand .brand-text br, .sidebar .brand .brand-sub { display: none; }
    .sidebar-links { flex-direction: row; align-items: center; gap: 14px; flex-wrap: nowrap; }
    .sidebar-links a { padding: 0; border-left: 0; font-size: 0.93rem; background: none; }
    .sidebar-links a.active { background: none; }
    .sidebar-links a.nav-cta { background: var(--accent); color: #fff; padding: 9px 18px; border-radius: 10px; font-weight: 600; font-size: 0.92rem; }
    /* Logged in: brand on the first row, the menu links (My Account / Licenses / Settings / Log out) as a scrollable row below. */
    .sidebar.logged-in { height: auto; flex-wrap: wrap; padding: 10px 18px 8px; row-gap: 8px; }
    .sidebar.logged-in .sidebar-links { width: 100%; overflow-x: auto; gap: 8px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
    .sidebar.logged-in .sidebar-links a, .sidebar.logged-in .sidebar-links .nav-logout { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; font-size: 0.9rem; width: auto; }
    .sidebar.logged-in .sidebar-links a.active { border-color: var(--accent); }
    .sidebar.logged-in .sidebar-links form { margin: 0; }
    .sidebar-links .nav-logout { padding: 0; font-size: 0.93rem; min-height: 0; }
    body { padding: 0; }
    .card, .card.wide { padding: 22px 18px 48px; }
    h1 { font-size: 1.7rem; }
    label { font-size: 1rem; }
    input[type="email"], input[type="text"] { padding: 13px 14px; font-size: 16px; }
    button { padding: 14px 18px; font-size: 1.05rem; min-height: 48px; }
    .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .hide-m { display: none; }
    .tabs { gap: 0; overflow-x: visible; }
    .tabs a { flex: 1 1 0; text-align: center; white-space: normal; padding: 10px 6px; font-size: 0.85rem; line-height: 1.25; }
    .tabs .count { display: block; margin: 3px auto 0; width: fit-content; }
    /* Tables with edit forms (customer.php): one card per row instead of a wide, horizontally scrolling table. */
    .card table.stack-m { display: block; overflow: visible; }
    .stack-m thead { display: none; }
    .stack-m tbody, .stack-m tr, .stack-m td { display: block; width: 100%; }
    .stack-m tr { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
    .stack-m td { border: 0; padding: 5px 0; }
    .stack-m td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 2px; }
    .stack-m td .inline-form { flex-wrap: wrap; }
    .stack-m td .inline-form input[type="text"], .stack-m td .inline-form input[type="datetime-local"] { width: 100%; flex: 1 1 100%; }
    .stack-m td .inline-form input[type="number"] { width: 84px; }
    .stack-m td .inline-form label { font-size: 0.95rem; }
    .stack-m td .inline-form button { flex: 1 1 auto; }
}
