* { box-sizing: border-box; }
/* Must win over .modal-overlay/.lock-overlay's own display:flex, which otherwise
   has equal CSS specificity to the browser's built-in [hidden] rule and overrides
   it - silently keeping "hidden" elements visible regardless of the hidden property. */
[hidden] { display: none !important; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #eef1f6;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
}
::selection { background: #bfdbfe; }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 20% 20%, #eef2ff 0%, #eef1f6 45%), #eef1f6;
}
.login-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 44px 40px;
    width: 360px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.04);
}
.login-card h1 { margin: 0 0 4px; font-size: 23px; color: #0f172a; letter-spacing: -0.01em; }
.subtitle { color: #64748b; font-size: 13px; margin-bottom: 26px; }
.login-terms { font-size: 11px; color: #94a3b8; line-height: 1.5; margin: 18px 0 0; text-align: left; }
.login-footer { text-align: center; font-size: 12px; color: #94a3b8; margin-top: 18px; }
.access-id-group { text-align: left; margin-bottom: 16px; }
.access-id-group label { display: block; font-size: 12px; font-weight: 600; color: #64748b; margin-bottom: 6px; letter-spacing: 0.01em; }
.code-input {
    width: 100%;
    font-size: 28px;
    letter-spacing: 10px;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    margin-bottom: 18px;
    transition: border-color .15s, box-shadow .15s;
}
.code-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.error-msg {
    display: block;
    background: #fef2f2;
    color: #b91c1c;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid #fecaca;
    text-align: left;
}
.info-msg {
    display: block;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #bfdbfe;
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: inline-block;
    border: none;
    border-radius: 9px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, box-shadow .15s, transform .05s;
}
.btn-primary { background: linear-gradient(180deg, #2f6ff0, #2354d6); color: #fff; width: 100%; box-shadow: 0 1px 2px rgba(37,99,235,0.3); }
.btn-primary:hover { background: linear-gradient(180deg, #2660e0, #1d4ec9); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: #ffffff; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: #ffffff;
    border-bottom: 1px solid #e5e9f0;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { font-size: 19px; margin: 0; color: #0f172a; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.signed-in-as { font-size: 13px; color: #64748b; margin-right: 4px; }
.signed-in-as strong { color: #1e293b; }

/* Brand mark */
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, #2f6ff0, #1e3a8a);
    color: #fff; font-size: 14px; font-weight: 800; letter-spacing: -0.02em;
    box-shadow: 0 1px 2px rgba(37,99,235,0.35);
}
.brand-name { font-size: 19px; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }

/* Notification bell */
.bell-link {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 9px; text-decoration: none;
    background: #ffffff; border: 1px solid #e2e8f0; font-size: 16px;
}
.bell-link:hover { background: #f1f5f9; }
.bell-badge {
    position: absolute; top: -6px; right: -6px;
    background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
    box-shadow: 0 0 0 2px #fff;
}

/* Footer */
.site-footer {
    text-align: center; font-size: 12px; color: #94a3b8;
    padding: 24px 20px 32px;
}
.footer-version { margin-left: 8px; color: #cbd5e1; }

/* Vendor color coding (left accent border on dashboard cards) */
.server-card { border-left-width: 4px; border-left-style: solid; }
.vendor-color-none { border-left-color: #e5e9f0; }
.vendor-color-0 { border-left-color: #2563eb; }
.vendor-color-1 { border-left-color: #16a34a; }
.vendor-color-2 { border-left-color: #d97706; }
.vendor-color-3 { border-left-color: #9333ea; }
.vendor-color-4 { border-left-color: #db2777; }
.vendor-color-5 { border-left-color: #0891b2; }
.vendor-color-6 { border-left-color: #ca8a04; }
.vendor-color-7 { border-left-color: #dc2626; }

/* Welcome banner */
.welcome-banner {
    margin: 20px 24px 0;
    padding: 18px 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
    border-radius: 14px;
    color: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
}
.welcome-title { font-size: 17px; font-weight: 600; }
.welcome-title strong { font-weight: 700; }
.welcome-sub { font-size: 12.5px; color: #dbe4ff; margin-top: 3px; }
.welcome-clock { font-size: 13px; font-variant-numeric: tabular-nums; color: #eef2ff; background: rgba(255,255,255,0.12); padding: 6px 12px; border-radius: 8px; }

/* Vendor badge */
.vendor-badge {
    display: inline-block;
    font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
    color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe;
    padding: 2px 8px; border-radius: 999px; margin-bottom: 6px;
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 20px 24px 24px;
}
.server-card {
    background: #ffffff;
    border: 1px solid #e5e9f0;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: box-shadow .15s, transform .15s;
}
.server-card:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.server-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.server-card-head h2 { font-size: 15px; margin: 0 0 10px; line-height: 1.3; color: #0f172a; font-weight: 600; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-link { font-size: 12px; color: #64748b; text-decoration: none; }
button.icon-link { background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; }
.icon-link:hover { color: #1e293b; }
.danger-link:hover { color: #dc2626; }
.summary-list { display: grid; grid-template-columns: 80px 1fr; row-gap: 4px; font-size: 13px; margin: 0 0 14px; }
.summary-list dt { color: #64748b; }
.summary-list dd { margin: 0; word-break: break-all; color: #1e293b; }
.btn-view { width: 100%; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    z-index: 50;
}
.modal {
    background: #ffffff;
    border-radius: 14px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}
.qr-modal { max-width: 380px; text-align: center; }
.qr-modal .cred-row { text-align: left; }
.modal-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: #64748b;
    font-size: 22px; cursor: pointer;
}
.modal-close:hover { color: #1e293b; }
.modal h2 { margin-top: 0; font-size: 18px; color: #0f172a; }
.modal h3 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; margin: 20px 0 8px; }
.cred-row {
    display: flex; align-items: center; gap: 8px;
    background: #f8fafc; border: 1px solid #e5e9f0;
    border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
    font-size: 13px;
}
.cred-row .cred-label { color: #64748b; width: 90px; flex-shrink: 0; }
.cred-row .cred-value { font-family: Consolas, monospace; flex: 1; word-break: break-all; color: #1e293b; }
.cred-row button {
    background: #e2e8f0; border: none; color: #1e293b;
    border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; flex-shrink: 0;
}
.cred-row button:hover { background: #cbd5e1; }
.notes-block {
    white-space: pre-wrap;
    background: #f8fafc; border: 1px solid #e5e9f0;
    border-radius: 8px; padding: 10px; font-size: 13px; font-family: Consolas, monospace;
    color: #1e293b;
}

/* Form page */
.form-page { max-width: 760px; margin: 0 auto; padding: 24px; }
.page-hint { color: #64748b; font-size: 13px; margin: -8px 0 20px; }
.field-group { margin-bottom: 16px; }
.field-row { display: flex; gap: 16px; }
.field-row .field-group { flex: 1; }
.field-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #475569; }
.field-group .hint { color: #94a3b8; font-weight: normal; font-size: 11px; margin-left: 6px; }
.text-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.text-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.text-input[readonly] { background: #f1f5f9; color: #64748b; }
.textarea { font-family: Consolas, monospace; font-size: 13px; }

/* Form sections (AddEditServer premium layout) */
.form-section {
    background: #ffffff; border: 1px solid #e5e9f0; border-radius: 12px;
    padding: 20px 22px; margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}
.form-section h3 { margin: 0 0 16px; font-size: 14px; color: #1e293b; font-weight: 700; }
.form-section h3 .hint { display: block; font-weight: normal; font-size: 11.5px; color: #94a3b8; margin-top: 4px; }

/* Dynamic repeatable rows (Logins / SQL Servers) */
.dyn-rows { margin-bottom: 10px; }
.dyn-row {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    background: #f8fafc; border: 1px solid #e5e9f0; border-radius: 8px;
    padding: 10px; margin-bottom: 8px;
}
.dyn-row .dyn-field { flex: 1 1 140px; min-width: 100px; }
.dyn-row .dyn-remove { flex-shrink: 0; padding: 8px 12px; font-size: 12px; }

/* Server code / dashboard extras */
.server-code {
    display: inline-block; font-size: 11px; font-weight: 700; color: #64748b;
    background: #f1f5f9; border-radius: 6px; padding: 1px 7px; margin: 0 0 6px 6px; vertical-align: middle;
}
.modal-subtitle { color: #64748b; font-size: 13px; margin: -6px 0 8px; }
.card-btn-row { display: flex; gap: 8px; }
.card-btn-row .btn-primary { flex: 2; }
.btn-rdp { flex: 1; text-align: center; font-size: 13px; padding: 10px 12px; }

/* Vendor document list */
.doc-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 20px; }
.doc-card {
    width: 140px; border: 1px solid #e5e9f0; border-radius: 10px; padding: 10px;
    background: #f8fafc; text-align: center; font-size: 12px;
}
.doc-card img { width: 100%; height: 80px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; background: #e2e8f0; }
.doc-card .doc-icon { width: 100%; height: 80px; display: flex; align-items: center; justify-content: center; border-radius: 6px; margin-bottom: 6px; background: #e2e8f0; font-size: 28px; }
.doc-card .doc-name { display: block; color: #1e293b; word-break: break-word; margin-bottom: 6px; }
.doc-card .doc-actions { display: flex; gap: 6px; justify-content: center; }
.doc-card .doc-actions a, .doc-card .doc-actions button { font-size: 11px; padding: 4px 8px; }

/* Mapped servers table (Vendor detail) */
.mapped-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mapped-table th { text-align: left; background: #f1f5f9; color: #475569; font-weight: 600; padding: 8px 10px; }
.mapped-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; color: #334155; }

/* Status summary cards (Cloud Server Status page) */
.status-summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.status-card { flex: 1; min-width: 150px; border-radius: 12px; padding: 16px 18px; color: #fff; }
.status-card .status-count { font-size: 28px; font-weight: 700; }
.status-card .status-label { font-size: 12.5px; opacity: .9; }
.status-card.status-active { background: linear-gradient(135deg,#16a34a,#22c55e); }
.status-card.status-expiring { background: linear-gradient(135deg,#d97706,#f59e0b); }
.status-card.status-expired { background: linear-gradient(135deg,#dc2626,#ef4444); }
.status-card.status-notset { background: linear-gradient(135deg,#64748b,#94a3b8); }
.status-pill { display:inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.status-pill.status-active { background:#dcfce7; color:#15803d; }
.status-pill.status-expiring { background:#fef3c7; color:#b45309; }
.status-pill.status-expired { background:#fee2e2; color:#b91c1c; }
.status-pill.status-notset { background:#e2e8f0; color:#475569; }

/* Access ID management */
.access-id-row {
    display: flex; align-items: center; justify-content: space-between;
    background: #f8fafc; border: 1px solid #e5e9f0;
    border-radius: 8px; padding: 10px 14px; margin-bottom: 8px;
    font-size: 14px; color: #1e293b;
}

/* Vendor form */
.vendor-form {
    background: #f8fafc; border: 1px solid #e5e9f0; border-radius: 12px;
    padding: 18px; margin-bottom: 24px;
}
.vendor-form h3 { margin-top: 0; font-size: 14px; color: #334155; }

/* Log tables */
.log-page .log-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }
.log-table th { text-align: left; background: #f1f5f9; color: #475569; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid #e5e9f0; }
.log-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; color: #334155; word-break: break-word; }
.log-table tr:last-child td { border-bottom: none; }
.log-table tr.log-fail td:nth-child(2) { color: #b91c1c; font-weight: 600; }
.log-table tr.log-ok td:nth-child(2) { color: #15803d; font-weight: 600; }

/* Lock screen overlay */
.lock-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 999;
}
.lock-card {
    background: #ffffff; border-radius: 16px; padding: 40px 36px;
    width: 320px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.lock-card h2 { margin: 0 0 4px; font-size: 19px; color: #0f172a; }
.lock-sub { color: #64748b; font-size: 13px; margin-bottom: 20px; }

@media (max-width: 500px) {
    .field-row { flex-direction: column; gap: 0; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .welcome-banner { flex-direction: column; align-items: flex-start; }
}
