/* JAppPortal - one stylesheet for every page the Portal renders except the session canvas.
   Colours are the Jonas palette used by the customer dashboard, so a user moving between the two products
   sees one brand. Replace the files in wwwroot/brand to rebrand; nothing here is compiled in. */

:root {
  --navy: #16233f;
  --navy-2: #1d2d50;
  --navy-line: rgba(255, 255, 255, 0.08);
  --on-navy: #c3ccdb;
  --primary: #1f59a4;
  --primary-hover: #184a87;
  --primary-soft: #eef2f8;
  --focus: rgba(31, 89, 164, 0.28);
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d4d8df;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
code { font: 0.9em ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- buttons and fields ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  font: 600 15px var(--font); cursor: pointer; text-decoration: none !important;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn-on-navy { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.22); }
.btn-on-navy:hover { background: rgba(255, 255, 255, 0.08); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input {
  display: block; width: 100%; height: 44px; padding: 0 12px;
  font: 15px var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; margin-bottom: 20px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.45;
  color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line);
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert code { background: rgba(255, 255, 255, 0.7); }
.alert-info { color: #1e3a66; background: var(--primary-soft); border-color: #d6e0ee; }

.divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0;
  color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* --- sign-in: brand panel on the left, the form on the right ------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 56px; color: var(--on-navy);
  background: radial-gradient(120% 90% at 0% 0%, var(--navy-2) 0%, var(--navy) 60%);
}
/* Two arcs echoing the circle of the J mark. Decorative only. */
.auth-brand::before, .auth-brand::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.auth-brand::before { width: 620px; height: 620px; right: -260px; bottom: -220px; background: rgba(31, 89, 164, 0.18); }
.auth-brand::after { width: 900px; height: 900px; right: -400px; bottom: -360px; }
.auth-brand-top { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 600; letter-spacing: .01em; }
.auth-brand-top img { width: 34px; height: 34px; }
.auth-brand-body { max-width: 420px; }
.auth-brand-body h1 { color: #fff; font-size: 38px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.auth-brand-body p { margin-top: 16px; font-size: 17px; line-height: 1.55; color: var(--on-navy); }
.auth-brand-foot { font-size: 13px; color: rgba(195, 204, 219, 0.7); }

.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px 24px 24px; }
.auth-card { width: 100%; max-width: 392px; margin: auto 0; }
.auth-logo { display: block; width: 48px; height: 48px; margin-bottom: 28px; }
.auth-card h2 { font-size: 26px; line-height: 1.25; }
.auth-sub { margin: 6px 0 28px; color: var(--muted); }
.auth-hint { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; }
/* The brand panel carries the copyright on a wide screen; this one is for when that panel is hidden. */
.auth-foot { display: none; margin-top: 40px; font-size: 12.5px; color: var(--faint); text-align: center; }
.auth-foot a { color: var(--muted); }

.status-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px;
  border-radius: 50%; color: var(--success); background: var(--success-soft);
}
.status-icon svg { width: 24px; height: 24px; }
.status-icon.warn { color: #a16207; background: #fefce8; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-foot { display: block; }
  .auth-main { background: var(--bg); padding-top: 40px; }
  .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
}
@media (max-width: 440px) {
  .auth-main { padding: 16px; }
  .auth-card { padding: 28px 20px; }
}

/* --- signed-in shell ---------------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 24px; background: var(--navy); color: #fff;
  border-bottom: 1px solid var(--navy-line);
}
.topbar-brand { display: flex; align-items: center; gap: 11px; color: #fff; font-weight: 600; font-size: 16px; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { width: 30px; height: 30px; }
.topbar-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.18); }
.topbar-company { color: var(--on-navy); font-weight: 400; }
.topbar-spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--on-navy); font-size: 14px; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.avatar {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; letter-spacing: .02em;
}

.page { max-width: 1120px; margin: 0 auto; padding: 36px 24px 56px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin-top: 4px; color: var(--muted); }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.app-tile {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.app-tile:hover { border-color: #c9d5e6; box-shadow: var(--shadow); transform: translateY(-1px); }
.app-open { display: flex; flex-direction: column; gap: 16px; padding: 20px; color: var(--text); flex: 1; }
.app-open:hover { text-decoration: none; }
.app-open:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); border-radius: 12px; }
.app-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  color: #fff; font-size: 20px; font-weight: 600;
}
.app-name { font-weight: 600; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.app-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; color: var(--primary); font-size: 14px; font-weight: 600; }
.app-cta svg { width: 16px; height: 16px; transition: transform .15s; }
.app-tile:hover .app-cta svg { transform: translateX(2px); }
.app-tile.unavailable .app-cta { color: var(--faint); }
.app-extra { border-top: 1px solid var(--border); padding: 10px 20px; font-size: 13px; }
.app-extra a { color: var(--muted); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 64px 24px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px;
}
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 14px; }
.empty h2 { font-size: 17px; }
.empty p { margin-top: 6px; color: var(--muted); max-width: 420px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 20px; }
.panel h2 { font-size: 16px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

.foot { max-width: 1120px; margin: 0 auto; padding: 0 24px 32px; color: var(--faint); font-size: 12.5px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Files (contracts 1.14.0): the home folder's folders on the left, the folder shown on the right. */
.files { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.files-places { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.files-place {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; border: 1px solid transparent;
}
.files-place:hover { background: var(--surface); text-decoration: none; }
.files-place.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.files-place svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.files-place.active svg { color: var(--primary); }
.files-place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-main {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 12px;
  border-style: solid; transition: border-color .15s, box-shadow .15s;
}
.files-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.files-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; min-width: 0; }
.files-crumbs span { color: var(--faint); font-weight: 400; }
.files-crumbs a { color: var(--text); overflow-wrap: anywhere; }
.files-crumbs a:last-child { color: var(--primary); }
.files-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.files-actions .btn svg { width: 16px; height: 16px; }
.files-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.files-pick:focus-within { box-shadow: 0 0 0 4px var(--focus); }
.files-hint { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.files-tip { margin: 12px 0 0; color: var(--faint); }
.files-empty { padding: 40px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.files-table td { vertical-align: middle; }
.files-table tbody tr { transition: background .1s; }
.files-table tbody tr:hover { background: var(--bg); }
.files-name a { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.files-name svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.files-table tr[data-drop] .files-name svg { color: #c08a1e; }
.files-size, .files-date { white-space: nowrap; color: var(--muted); width: 1%; }
.files-row-actions { width: 1%; white-space: nowrap; text-align: right; }
.files-row-actions form { display: inline; }
.files-icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.files-icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.files-icon-btn svg { width: 17px; height: 17px; }
.files-drop-on { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft) !important; }
.files-main.files-drop-on { box-shadow: 0 0 0 4px var(--focus); }
.files-progress {
  max-height: 220px; overflow: auto; margin: 0 0 12px; padding: 10px 12px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.files-progress div { padding: 2px 0; overflow-wrap: anywhere; }
.files-progress .head { font-weight: 600; }
.files-progress .ok { color: var(--success); }
.files-progress .bad { color: var(--danger); }
.files-progress .btn { margin-top: 8px; }
/* In the panel beside an app (?embed=1): narrow, so the folders are a row of chips and the date gives way. */
body.embed .page { max-width: none; padding: 12px; }
body.embed .files-main { padding: 12px; }
body.embed .files-places { scrollbar-width: thin; }
body.embed .files-date { display: none; }
body.embed .files-actions .btn span { display: none; }
body.embed .files-actions .btn { padding: 0 9px; }
body.embed .files-toast { bottom: 12px; }
.files-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 14px; box-shadow: var(--shadow);
  pointer-events: none;
}

@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-sep, .topbar-company, .user-name { display: none; }
  .page { padding: 24px 16px 40px; }
  .app-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .app-open { padding: 16px; }
  .foot { padding: 0 16px 24px; }
  .files-main { padding: 12px; }
  .files-date { display: none; }
}
@media (max-width: 900px) {
  .files { grid-template-columns: 1fr; gap: 12px; }
  .files-places { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .files-place { flex: none; background: var(--surface); border-color: var(--border); }
}
@media (max-width: 380px) { .app-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
