/* AppProxy portal: navy top bar with a gold rule, centred search, pill tabs
   with gold counters and a grid of app cards. */
:root {
  --navy-900: #14213d;
  --navy-800: #1b2b4b;
  --navy-700: #0f4a70;
  --gold: #f5b800;
  --gold-soft: #f7c948;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --page: #ffffff;
  --chip: #f1f3f6;
  --tabs-bg: #eef3fa;
  --tabs-line: #d6e2f1;
  --danger: #b3261e;
  --focus: #2563eb;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 4%);
  --shadow-hover: 0 8px 24px rgb(16 24 40 / 10%);
  /* Device fonts only (PO decision): no web fonts are downloaded. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
img { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link { position: absolute; left: 1rem; top: -3rem; padding: .5rem .75rem; background: var(--gold); color: var(--navy-900); font-weight: 600; border-radius: 4px; z-index: 10; }
.skip-link:focus { top: .5rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 44px; padding: .25rem clamp(1rem, 4vw, 3rem);
  background: var(--navy-900); color: #fff; border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; font-weight: 600; font-size: 1rem; letter-spacing: .1px; }
.brand img { width: 30px; height: 30px; }
.account { display: flex; align-items: center; gap: .75rem; font-size: .875rem; }
.account form { margin: 0; }
.lang-switch { display: flex; gap: 2px; padding: 2px; border: 1px solid rgb(255 255 255 / 30%); border-radius: 5px; }
.lang-switch a { padding: .15rem .45rem; border-radius: 3px; color: #fff; font-size: .72rem; font-weight: 700; letter-spacing: .4px; text-decoration: none; opacity: .75; }
.lang-switch a:hover { opacity: 1; background: rgb(255 255 255 / 12%); }
.lang-switch a[aria-current="true"] { opacity: 1; background: var(--gold); color: var(--navy-900); }
.account-name { opacity: .9; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem; }
main:focus { outline: none; }

/* Search + tools */
.toolbar { display: flex; justify-content: center; align-items: center; gap: .6rem; margin: .25rem auto 1.5rem; }
.search {
  display: flex; align-items: center; gap: .6rem; width: min(470px, 100%);
  padding: 4px; border: 2px solid var(--navy-800); border-radius: var(--radius); background: var(--surface);
}
.search:focus-within { box-shadow: 0 0 0 3px rgb(37 99 235 / 25%); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: .78rem; color: var(--ink); background: transparent; }
.search input::placeholder { color: #8a93a3; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-btn {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 6px; background: var(--navy-800); color: var(--gold); cursor: pointer;
}
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--chip); color: var(--navy-800); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: #e6eaf0; }
.icon-btn[aria-pressed="true"] { background: var(--navy-800); color: var(--gold); border-color: var(--navy-800); }

/* Category tabs */
.tabs {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  width: fit-content; max-width: 100%; margin: 0 auto 2rem; padding: 5px;
  background: var(--tabs-bg); border: 1px solid var(--tabs-line); border-radius: 10px;
}
.tab {
  display: inline-flex; align-items: center; gap: .55rem; padding: .45rem .9rem;
  border-radius: 7px; color: var(--navy-800); font-weight: 700; font-size: .8rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.tab:hover { background: #dfe7f2; }
.tab[aria-selected="true"] { background: var(--navy-800); color: #fff; box-shadow: 0 1px 2px rgb(16 24 40 / 20%); }
.count {
  display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--gold); color: var(--navy-900); font-size: .7rem; font-weight: 800;
}

/* Cards */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .grid { grid-template-columns: 1fr; } }

.card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 1.15rem 1rem 1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-card);
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.app-icon { width: 56px; height: 56px; border-radius: 6px; object-fit: contain; margin-bottom: .85rem; }
.card-title { margin: 0 0 .45rem; font-size: .84rem; font-weight: 700; line-height: 1.4; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc { margin: 0 0 .85rem; font-size: .7rem; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin: 0 0 .75rem; padding: 0; list-style: none; }
.tags li { padding: .1rem .4rem; border-radius: 4px; background: var(--chip); font-size: .62rem; font-weight: 600; color: var(--ink); }
.actions { display: flex; justify-content: center; align-items: center; gap: .5rem; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 5px; border: 1px solid transparent;
  font: inherit; font-size: .875rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-sm { padding: .32rem 1.55rem; font-size: .7rem; border-radius: 4px; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-900); }
.btn-secondary { background: var(--surface); color: var(--navy-800); border-color: var(--navy-800); }
.btn-secondary:hover { background: var(--tabs-bg); }
.btn-outline { background: var(--surface); color: var(--navy-800); border-color: var(--navy-800); }
.btn-outline:hover { background: var(--navy-800); color: var(--gold); }
.btn-square { width: 24px; height: 24px; padding: 0; border-radius: 4px; }
.btn-ghost { padding: .3rem .8rem; background: transparent; color: #fff; border-color: rgb(255 255 255 / 45%); font-size: .8rem; }
.btn-ghost:hover { background: rgb(255 255 255 / 12%); border-color: var(--gold); }
.btn-block { width: 100%; }

/* Login, messages, detail */
.panel { max-width: 44rem; margin: 2rem auto; padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.panel.narrow { max-width: 26rem; }
.panel h1 { margin: 0 0 .5rem; font-size: 1.4rem; color: var(--navy-900); }
.lead { margin: 0 0 1.25rem; color: var(--muted); font-size: .9rem; }
.stack { display: grid; gap: .35rem; }
.stack label { margin-top: .5rem; font-weight: 600; font-size: .85rem; }
.stack input { width: 100%; padding: .65rem .75rem; font: inherit; border: 1px solid #c9d1dc; border-radius: 6px; }
.stack input:focus-visible { border-color: var(--navy-800); }
.stack .btn { margin-top: 1rem; }
.alert { padding: .75rem; border-radius: 6px; border: 1px solid var(--danger); background: #fdf2f1; color: var(--danger); font-size: .9rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8rem; margin: 1.25rem 0 .25rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.hint, .muted { color: var(--muted); font-size: .85rem; }

.detail-dialog { width: min(36rem, 92vw); padding: 0; border: 0; border-radius: 10px; box-shadow: 0 24px 64px rgb(16 24 40 / 30%); }
.detail-dialog::backdrop { background: rgb(20 33 61 / 55%); }
.detail { padding: 1.75rem; font-size: .88rem; }
.detail code { font-size: .8rem; }
.detail-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.detail-head .app-icon { margin: 0; flex: none; }
.detail-head .tags { justify-content: flex-start; margin: .35rem 0 0; }
.detail-title { margin: 0; font-size: 1.2rem; color: var(--navy-900); }
.detail-sub { font-size: .95rem; margin: 1.25rem 0 .4rem; color: var(--navy-800); }
.access-info { white-space: pre-line; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .85rem; margin: 1rem 0 1.5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.detail .actions { justify-content: flex-start; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}
