:root {
    --accent: #0f6cbd;
    --accent-hover: #115ea3;
    --accent-pressed: #0c3b5e;
    --accent-tint: #ebf3fc;
    --bg: #f5f5f5;
    --bg-elevated: #ffffff;
    --stroke: #e0e0e0;
    --stroke-strong: #d1d1d1;
    --text: #242424;
    --text-secondary: #616161;
    --text-disabled: #bdbdbd;
    --danger: #c50f1f;
    --danger-bg: #fdf3f4;
    --success: #0e700e;
    --success-bg: #f1faf1;
    --warning: #9a5a00;
    --warning-bg: #fff9f0;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-2: 0 1.6px 3.6px rgba(0,0,0,.08), 0 .3px .9px rgba(0,0,0,.06);
    --shadow-8: 0 3.2px 7.2px rgba(0,0,0,.10), 0 .6px 1.8px rgba(0,0,0,.08);
    --shadow-16: 0 6.4px 14.4px rgba(0,0,0,.12), 0 1.2px 3.6px rgba(0,0,0,.10);
    --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---------- Header ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--stroke);
}
.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 28px;
    height: 56px;
    padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-text strong { color: var(--accent); }
.brand-mark {
    display: grid;
    grid-template-columns: 9px 9px;
    grid-template-rows: 9px 9px;
    gap: 2px;
}
.brand-mark span { background: var(--accent); border-radius: 1px; }
.brand-mark span:nth-child(2) { background: #2886de; }
.brand-mark span:nth-child(3) { background: #50abff; }
.brand-mark span:nth-child(4) { background: #0c3b5e; }

.app-nav { display: flex; gap: 4px; flex: 1; }
.app-nav a {
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
}
.app-nav a:hover { background: rgba(0,0,0,.04); color: var(--text); text-decoration: none; }

.app-header-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; color: var(--text); }
.user-chip:hover { background: rgba(0,0,0,.04); text-decoration: none; }
.user-chip-name { font-weight: 500; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #50abff);
    color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.inline { display: inline; margin: 0; }

/* ---------- Layout ---------- */
.app-main { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1200px 600px at 20% -10%, #e8f1fc 0%, transparent 60%),
                radial-gradient(1000px 500px at 100% 0%, #eef6ff 0%, transparent 55%), var(--bg); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--text-secondary); margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--stroke);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}
.card-pad { padding: 24px; }

/* ---------- Target tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tile {
    position: relative;
    background: var(--bg-elevated);
    border: 1px solid var(--stroke);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-2);
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
    display: flex; flex-direction: column; gap: 14px; min-height: 164px;
}
.tile:hover { box-shadow: var(--shadow-8); transform: translateY(-1px); border-color: var(--stroke-strong); }
.tile.at-capacity { opacity: .55; filter: grayscale(.9); pointer-events: none; }
.tile.at-capacity .tile-cta { cursor: not-allowed; }

.tile-top { display: flex; align-items: flex-start; gap: 12px; }
.proto-badge {
    width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
    font-weight: 700; font-size: 12px; letter-spacing: .04em; color: #fff; flex: none;
}
.proto-ssh { background: linear-gradient(135deg,#0e700e,#5bbf5b); }
.proto-rdp { background: linear-gradient(135deg,#0f6cbd,#50abff); }
.tile-title { font-weight: 600; font-size: 15px; }
.tile-sub { color: var(--text-secondary); font-size: 12.5px; word-break: break-all; }

.tile-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #f0f0f0; color: var(--text-secondary);
    border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 500;
}
.chip.owner { background: var(--accent-tint); color: var(--accent); }
.chip.shared { background: #f3effc; color: #5c2e91; }
.chip.cap-ok { background: var(--success-bg); color: var(--success); }
.chip.cap-full { background: var(--danger-bg); color: var(--danger); }

.tile-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-cta { flex: 1; }
.tile-manage { display: flex; gap: 6px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-size: 14px; font-weight: 600;
    border-radius: var(--radius); border: 1px solid transparent;
    padding: 8px 16px; cursor: pointer; transition: background .12s ease, border-color .12s ease; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:active { background: var(--accent-pressed); }
.btn-primary:disabled { background: var(--text-disabled); cursor: not-allowed; }
.btn-default { background: #fff; color: var(--text); border-color: var(--stroke-strong); }
.btn-default:hover { background: #f5f5f5; }
.btn-subtle { background: transparent; color: var(--text); border-color: transparent; }
.btn-subtle:hover { background: rgba(0,0,0,.05); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f1bcc0; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--text-secondary); font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=datetime-local], select, textarea {
    font-family: inherit; font-size: 14px; color: var(--text);
    padding: 9px 12px; border: 1px solid var(--stroke-strong); border-radius: var(--radius);
    background: #fff; width: 100%; transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15,108,189,.2);
}
textarea { resize: vertical; min-height: 110px; font-family: "Cascadia Code", "Consolas", monospace; font-size: 12.5px; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

.validation-summary-errors, .field-validation-error, .text-danger { color: var(--danger); font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); padding: 12px 16px; font-size: 13.5px; border: 1px solid transparent; margin-bottom: 16px; }
.alert-info { background: var(--accent-tint); border-color: #cfe4fa; color: var(--accent-hover); }
.alert-success { background: var(--success-bg); border-color: #c5e8c5; color: var(--success); }
.alert-danger { background: var(--danger-bg); border-color: #f1c7cb; color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: #f5e0bf; color: var(--warning); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); padding: 10px 12px; border-bottom: 1px solid var(--stroke); }
.table td { padding: 12px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* ---------- Auth card ---------- */
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-pad { padding: 32px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-logo .brand-mark { grid-template-columns: 12px 12px; grid-template-rows: 12px 12px; }
.auth-title { font-size: 22px; }
.auth-sub { color: var(--text-secondary); margin-bottom: 24px; }
.auth-sep { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); font-size: 12px; margin: 20px 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

/* ---------- Misc ---------- */
.muted { color: var(--text-secondary); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.mono { font-family: "Cascadia Code", "Consolas", monospace; }
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-secondary); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }
.qr { background:#fff; padding:12px; border:1px solid var(--stroke); border-radius: var(--radius); display:inline-block; }
code.key { background:#f0f0f0; padding:3px 8px; border-radius:6px; font-family:"Cascadia Code","Consolas",monospace; }
.toolbar { display:flex; gap:10px; flex-wrap: wrap; align-items:center; }

/* ---------- Recording consent overlay ---------- */
.consent-overlay { position:fixed; inset:0; z-index:200; background:rgba(16,24,40,.72);
    backdrop-filter: blur(4px); display:grid; place-items:center; padding:24px; }
.consent-card { background:#fff; border-radius:var(--radius-lg); max-width:480px; width:100%;
    box-shadow:var(--shadow-16); overflow:hidden; }
.consent-head { display:flex; align-items:center; gap:12px; padding:20px 24px; background:var(--accent-tint);
    border-bottom:1px solid #cfe4fa; color:var(--accent-hover); }
.consent-head .rec-dot { width:12px; height:12px; border-radius:50%; background:var(--danger);
    box-shadow:0 0 0 4px rgba(197,15,31,.18); animation:recpulse 1.6s infinite; }
@keyframes recpulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.consent-body { padding:22px 24px; }
.consent-body h2 { margin:0 0 10px; }
.consent-actions { display:flex; gap:10px; padding:0 24px 22px; }
.rec-indicator { display:inline-flex; align-items:center; gap:7px; color:#ff6b6b; font-size:12.5px; font-weight:600; }
.rec-indicator .rec-dot { width:9px; height:9px; border-radius:50%; background:#f85149; animation:recpulse 1.6s infinite; }

/* ---------- Recording player ---------- */
.rec-player { background:#000; border-radius:0 0 10px 10px; padding:8px; height:66vh; }
.rec-controls { display:flex; align-items:center; gap:14px; background:#1f1f1f; color:#fff;
    padding:10px 16px; border-radius:0 0 10px 10px; }
.rec-controls input[type=range] { flex:1; accent-color:var(--accent); }
.rec-controls .time { font-family:"Cascadia Code","Consolas",monospace; font-size:12.5px; color:#b0b0b0; min-width:96px; }

/* ---------- Session extras ---------- */
.expiry-chip { display:inline-flex; align-items:center; gap:4px; padding:2px 9px; border-radius:999px; font-size:12px;
    font-variant-numeric: tabular-nums; background:rgba(255,255,255,.1); color:#e6e6e6; }
.expiry-chip.warn { background:#9a5a00; color:#fff; }
.expiry-chip.expired { background:#c50f1f; color:#fff; }
.tile-note { margin-top:10px; padding:8px 10px; border-radius:var(--radius); background:var(--warning-bg); color:#5c3c00;
    font-size:12.5px; white-space:pre-wrap; overflow-wrap:anywhere; max-height:7.5em; overflow:auto; border:1px solid #f3dfbf; }
.tile-note::before { content:"📝 "; }
.chip.hidden-info { background:#f0f0f0; color:var(--text-secondary); }
.fa-select { width:auto; padding:2px 8px; font-size:12px; border-radius:999px; min-height:0; height:auto; }
.older-form { display:inline-flex; align-items:center; gap:6px; }
.older-form input[type=number] { width:76px; padding:6px 8px; }
.tile-actions { display:flex; gap:6px; flex:1; }
.tile-actions form { flex:1; margin:0; }
.preset-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; }
.preset-card { border:1px solid var(--stroke); border-radius:var(--radius); padding:10px 12px; cursor:pointer; display:block; }
.preset-card:has(input:checked) { border-color:var(--accent); background:var(--accent-tint); box-shadow:0 0 0 1px var(--accent) inset; }
.preset-card input { margin-right:6px; }
.preset-card .muted { display:block; font-size:12px; margin-top:4px; }
@media (max-width: 640px) {
    .field-row { grid-template-columns: 1fr; }
    .app-nav { display: none; }
}

/* Dashboard live search */
.dash-search-bar { display: flex; align-items: center; gap: 14px; margin: -8px 0 16px; flex-wrap: wrap; }
.dash-search { position: relative; flex: 1 1 360px; max-width: 560px; display: flex; align-items: center; }
.dash-search svg { position: absolute; left: 12px; color: var(--text-secondary); pointer-events: none; }
.dash-search input {
    width: 100%; height: 38px; margin: 0; padding: 0 40px 0 36px; font: inherit; color: var(--text);
    background: var(--bg-elevated); border: 1px solid var(--stroke-strong); border-bottom-color: #8a8a8a;
    border-radius: var(--radius); outline: none; transition: border-color .12s, box-shadow .12s;
}
.dash-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dash-search input::-webkit-search-cancel-button { cursor: pointer; }
.dash-search kbd {
    position: absolute; right: 10px; font: 11px/1 var(--font); color: var(--text-secondary);
    border: 1px solid var(--stroke-strong); border-radius: 4px; padding: 3px 6px; background: var(--bg); pointer-events: none;
}
.dash-search input:focus ~ kbd, .dash-search input:not(:placeholder-shown) ~ kbd { display: none; }
.tile[hidden] { display: none !important; }
.tile mark { background: #fff1a8; color: inherit; border-radius: 2px; padding: 0 1px; }
.chip mark, .proto-badge mark { background: rgba(255, 225, 80, .75); }
#tile-grid[hidden], #target-search-empty[hidden] { display: none !important; }
