/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
}

a { color: #4a90e2; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell layout ─────────────────────────────────────────────────────────── */
.portal-shell {
    display: flex;
    min-height: 100vh;
}

.portal-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    background: #1e2a3a;
    color: #c8d6e5;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 24px 20px 16px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #2d3f54;
}

.sidebar ul {
    list-style: none;
    flex: 1;
    padding: 8px 0;
}

.sidebar ul li a {
    display: block;
    padding: 10px 20px;
    color: #c8d6e5;
    font-size: 13px;
    transition: background 0.15s;
    position: relative;
}

.sidebar ul li a:hover {
    background: #2d3f54;
    color: #fff;
    text-decoration: none;
}

.sidebar .nav-divider {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5a7a9a;
}

.sidebar .badge {
    background: #e24b4a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid #2d3f54;
    font-size: 12px;
    color: #7a9ab8;
}

.sidebar-user span {
    display: block;
    margin-bottom: 8px;
    word-break: break-all;
}

.sidebar-user button {
    background: none;
    border: 1px solid #2d3f54;
    color: #7a9ab8;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.sidebar-user button:hover { background: #2d3f54; color: #fff; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #1e2a3a;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background: #4a90e2;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: #357abd; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    background: #e8edf2;
    color: #333;
    border: 1px solid #cdd5de;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-secondary:hover { background: #d8e0ea; text-decoration: none; }

.btn-link {
    background: none;
    border: none;
    color: #4a90e2;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.btn-danger { color: #e24b4a; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled { background: #f4f6f8; }

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-card {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.required { color: #e24b4a; }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
}

.toggle-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error   { background: #fdecea; border: 1px solid #f5c6c6; color: #a32d2d; }
.alert-success { background: #eaf3de; border: 1px solid #b8dba0; color: #3b6d11; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dde3ec;
    font-size: 13px;
}

.portal-table th {
    background: #f4f6f9;
    padding: 11px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #6b7c93;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-bottom: 1px solid #dde3ec;
}

.portal-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f2f5;
    color: #333;
}

.portal-table tr:last-child td { border-bottom: none; }
.portal-table tr:hover td { background: #f8f9fb; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.status-open       { background: #e6f1fb; color: #185fa5; }
.status-inprogress { background: #faeeda; color: #854f0b; }
.status-resolved   { background: #eaf3de; color: #3b6d11; }
.status-closed     { background: #f0f2f5; color: #6b7c93; }

.priority-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.priority-low      { background: #f0f2f5; color: #6b7c93; }
.priority-normal   { background: #e6f1fb; color: #185fa5; }
.priority-high     { background: #faeeda; color: #854f0b; }
.priority-critical { background: #fcebeb; color: #a32d2d; }

/* ── Dashboard cards ──────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.dash-card {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    text-align: center;
    transition: box-shadow 0.15s;
}
.dash-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.dash-icon  { font-size: 28px; margin-bottom: 8px; }
.dash-label { font-size: 12px; color: #6b7c93; margin-bottom: 6px; }
.dash-value { font-size: 22px; font-weight: 700; color: #1e2a3a; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f2f5;
}
.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-card h2 { font-size: 20px; margin-bottom: 6px; color: #1e2a3a; }
.auth-subtitle { font-size: 13px; color: #6b7c93; margin-bottom: 24px; }

/* ── Tickets ──────────────────────────────────────────────────────────────── */
.ticket-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6b7c93;
    margin-bottom: 20px;
}
.ticket-description {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}
.ticket-description h3 { font-size: 14px; margin-bottom: 10px; color: #1e2a3a; }
.ticket-description p  { line-height: 1.7; white-space: pre-wrap; }

.replies { margin-bottom: 24px; }
.replies h3 { font-size: 14px; margin-bottom: 12px; color: #1e2a3a; }

.reply {
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
}
.reply-admin    { background: #e6f1fb; border-left: 3px solid #4a90e2; }
.reply-customer { background: #f4f6f9; border-left: 3px solid #cdd5de; }
.reply-header   { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; color: #6b7c93; }
.reply-body     { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

.reply-form { background: #fff; border: 1px solid #dde3ec; border-radius: 10px; padding: 20px; }
.reply-form h3 { font-size: 14px; margin-bottom: 12px; }
.reply-form textarea { width: 100%; padding: 10px; border: 1px solid #cdd5de; border-radius: 6px; font-family: inherit; font-size: 13px; resize: vertical; margin-bottom: 12px; }

/* ── Notifications ────────────────────────────────────────────────────────── */
.notifications-list { display: flex; flex-direction: column; gap: 8px; }
.notification-item {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 8px;
    padding: 14px 16px;
    cursor: pointer;
    position: relative;
    transition: box-shadow 0.15s;
}
.notification-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.notification-item.unread { border-left: 3px solid #4a90e2; }
.notification-item.read   { opacity: 0.75; }
.notif-title   { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.notif-message { font-size: 12px; color: #6b7c93; margin-bottom: 6px; }
.notif-date    { font-size: 11px; color: #a0aab4; }
.unread-dot    { position: absolute; top: 14px; right: 14px; width: 8px; height: 8px; background: #4a90e2; border-radius: 50%; }

/* ── FAQs ─────────────────────────────────────────────────────────────────── */
.category-header { font-size: 16px; color: #1e2a3a; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 2px solid #dde3ec; }

.faq-item { background: #fff; border: 1px solid #dde3ec; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}
.faq-question:hover { background: #f8f9fb; }
.faq-chevron { font-size: 11px; color: #6b7c93; }
.faq-answer  { padding: 12px 16px 16px; font-size: 13px; line-height: 1.7; color: #555; border-top: 1px solid #f0f2f5; white-space: pre-wrap; }

/* ── Guides ───────────────────────────────────────────────────────────────── */
.guides-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; margin-bottom: 20px; }
.guide-card {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 18px;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.guide-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.guide-title   { font-weight: 600; font-size: 14px; margin-bottom: 8px; color: #1e2a3a; }
.guide-preview { font-size: 12px; color: #6b7c93; line-height: 1.5; }
.guide-detail  { background: #fff; border: 1px solid #dde3ec; border-radius: 10px; padding: 28px; }
.guide-detail h2 { font-size: 20px; margin-bottom: 6px; }
.guide-meta    { font-size: 12px; color: #6b7c93; margin-bottom: 20px; }
.guide-content p { margin-bottom: 12px; line-height: 1.7; font-size: 14px; }

/* ── License info rows ────────────────────────────────────────────────────── */
.info-row { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.info-row label { font-weight: 600; color: #6b7c93; min-width: 140px; }
.license-key { font-family: monospace; font-size: 13px; }

/* ── Section header ───────────────────────────────────────────────────────── */
.section-header { font-size: 15px; font-weight: 600; color: #1e2a3a; margin: 24px 0 12px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { color: #6b7c93; font-size: 13px; padding: 20px 0; }

/* ── Filter row ───────────────────────────────────────────────────────────── */
.filter-row select { padding: 7px 10px; border: 1px solid #cdd5de; border-radius: 6px; font-size: 13px; }

/* ── Version badge ────────────────────────────────────────────────────────── */
.version-badge {
    position: fixed;
    bottom: 10px;
    left: 12px;
    font-size: 11px;
    color: #aaa;
    font-family: Arial, sans-serif;
    z-index: 1000;
    user-select: none;
    background: rgba(255,255,255,0.85);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

/* ── Form row in ticket admin ─────────────────────────────────────────────── */
.form-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ── Invite-only auth styles ─────────────────────────────────────────────── */
.auth-section {
    margin-bottom: 20px;
}

.auth-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e2a3a;
    margin-bottom: 4px;
}

.auth-divider {
    text-align: center;
    color: #aaa;
    font-size: 12px;
    margin: 20px 0;
    border-top: 1px solid #eee;
    padding-top: 16px;
}

.invite-section {
    background: #f0f7ff;
    border: 1px solid #b5d4f4;
    border-radius: 8px;
    padding: 16px;
}

/* ── Purchase Orders ──────────────────────────────────────────────────────── */
.po-summary-card {
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.po-meta {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.meta-block label {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.meta-block span { font-size: 14px; color: #333; }

.po-totals {
    margin-left: auto;
    width: 280px;
    margin-bottom: 20px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid #f0f2f5;
}

.total-row {
    font-weight: 700;
    font-size: 16px;
    border-top: 2px solid #1e2a3a;
    border-bottom: none;
    padding-top: 10px;
    margin-top: 4px;
}

.line-item-row {
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.line-item-row .form-group {
    margin-bottom: 0;
}

.active-link {
    color: #3b6d11;
    font-weight: 600;
}

.notes-section {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
}

.notes-section h4 {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ── Downloads ────────────────────────────────────────────────────────────── */
.downloads-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.download-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 10px;
    padding: 16px 20px;
    transition: box-shadow 0.15s;
}

.download-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.07); }

.download-icon { font-size: 28px; flex-shrink: 0; }

.download-info { flex: 1; }

.download-title {
    font-weight: 600;
    font-size: 14px;
    color: #1e2a3a;
    margin-bottom: 4px;
}

.download-desc {
    font-size: 12px;
    color: #6b7c93;
    margin-bottom: 6px;
}

.download-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
}

.download-version {
    background: #e6f1fb;
    color: #185fa5;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.download-size {
    color: #aaa;
    padding: 2px 0;
}

.btn-download {
    background: #4a90e2;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-download:hover {
    background: #357abd;
    color: #fff;
    text-decoration: none;
}

/* ── Downloads table ─────────────────────────────────────────────────────── */
.downloads-table .download-desc-cell {
    color: #6b7c93;
    font-size: 13px;
    max-width: 300px;
}

.btn-download-sm {
    background: #4a90e2;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s;
}

.btn-download-sm:hover { background: #357abd; }

/* ── Tier badges ─────────────────────────────────────────────────────────── */
.tier-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.tier-free        { background: #f0f2f5; color: #6b7c93; }
.tier-pro500      { background: #e6f1fb; color: #185fa5; }
.tier-pro1000     { background: #eaf3de; color: #3b6d11; }
.tier-pro3000     { background: #faeeda; color: #854f0b; }
.tier-pro5000     { background: #ede8fb; color: #5a2d91; }
.tier-unlimited   { background: #1e2a3a; color: #fff;    }

/* ── Dropdown list box editor ─────────────────────────────────────────────── */
.dd-editor-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.dd-editor { display: flex; flex-direction: column; gap: 6px; }
.dd-label  { font-size: 12px; font-weight: 600; color: #555; }

.dd-listbox {
    width: 100%;
    min-height: 130px;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    padding: 4px;
    background: #fff;
}

.dd-listbox option { padding: 3px 6px; }
.dd-listbox option:checked { background: #4a90e2; color: #fff; }

.dd-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.dd-input {
    flex: 1;
    min-width: 100px;
    padding: 5px 8px !important;
    font-size: 12px !important;
    font-family: 'Courier New', monospace !important;
    border: 1px solid #cdd5de !important;
    border-radius: 5px !important;
}

.dd-btn {
    padding: 4px 10px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
}

.full-width-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .dd-editor-grid { grid-template-columns: 1fr; }
}

/* ── AppConfig Column Editor ─────────────────────────────────────────────── */
.col-add-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.col-add-row .form-group { margin-bottom: 0; }
.col-add-row select,
.col-add-row input { font-size: 12px !important; padding: 6px 8px !important; }

.col-table { font-size: 12px; }
.col-table code { font-size: 11px; }

.filter-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}
.filter-none           { background:#f0f2f5; color:#6b7c93; }
.filter-wildcard-filter { background:#e6f1fb; color:#185fa5; }
.filter-dropdown-filter { background:#eaf3de; color:#3b6d11; }
.filter-zip             { background:#faeeda; color:#854f0b; }

.pin-dot {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin: 0 3px;
    border: 1px solid rgba(0,0,0,0.15);
}

.col-summary {
    background: #f8f9fb;
    border: 1px solid #dde3ec;
    border-radius: 6px;
    padding: 8px 12px;
}
.col-summary-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 12px;
}
.col-summary-row:last-child { border-bottom: none; }
.col-name    { font-family: monospace; font-size: 11px; color: #c0392b; min-width: 140px; }
.col-display { color: #2c3e50; min-width: 120px; }

/* ── Dropdown editor (new) ───────────────────────────────────────────────── */
.dd-add-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.dd-add-row .form-group { margin-bottom: 0; }
.dd-add-row input,
.dd-add-row select { font-size: 13px !important; }

.dd-check-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}
.dd-check-group label { font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; }
.dd-checkbox { width: 18px; height: 18px; cursor: pointer; }

.dd-list-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.dd-listbox {
    flex: 1;
    min-height: 140px;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    padding: 4px;
    background: #fff;
}
.dd-listbox option { padding: 3px 6px; }

.dd-list-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dd-btn {
    padding: 5px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
}
