/* CPT/SIP dashboard — one dark theme, shared with every app (see /__cptsip/theme/*.css). */
:root {
  --bg: #10151b; --panel: #18212a; --panel2: #212c37; --line: #2e3b48; --text: #e8edf2; --muted: #93a1ae;
  --accent: #2f8fd8; --accent-ink: #fff; --brand: #1b2a35; --orange: #00b7e8;
  --good: #4ade80; --warn: #fbbf24; --bad: #f87171; --radius: 12px; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* hidden always wins (label.f sets display:block) */
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #7cc4ff; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: #0f141a; border: 1px solid var(--line); border-radius: 9px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
textarea { min-height: 6rem; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: .55rem .95rem; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #46a2ea; }
button.danger { color: var(--bad); }
button.small { padding: .28rem .65rem; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

/* layout */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.brandrow { display: flex; align-items: center; justify-content: space-between; }
.menubtn { display: none; }
.side { background: linear-gradient(180deg, #1b2a35 0%, #141d26 60%, #10161d 100%); border-right: 1px solid #25303c; padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: .2rem .6rem 1.2rem; display: block; }
.side .brand img { height: 46px; display: block; }
.side a { color: #d6e0ea; text-decoration: none; padding: .5rem .65rem; border-radius: 9px; display: flex; align-items: center; gap: .65rem; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.on { background: rgba(47,143,216,.35); color: #fff; font-weight: 600; }
.side .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .ico svg { width: 18px; height: 18px; display: block; }
.side .navhead { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #8796a5; padding: 1rem .65rem .35rem; }
.side .appl .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 4px; }
.side .appl .ext { margin-left: auto; opacity: .45; font-size: 12px; }
.side .grow { flex: 1; min-height: 1rem; }
.side .who { color: #8796a5; font-size: 13px; padding: .5rem .65rem 0; }
.side .signout { color: #c2ccd6; font-size: 14px; }
.main { padding: 1.8rem 2.2rem 4rem; max-width: 1200px; width: 100%; min-width: 0; }
h1, h2, p, td, .help, label.f { overflow-wrap: anywhere; }
h1 { font-size: 1.55rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.8rem 0 .7rem; }
.sub { color: var(--muted); margin: 0 0 1.3rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.row > select { width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem 1rem; }
label.f { display: block; font-size: 13px; color: var(--muted); }
label.f > span { display: block; margin-bottom: .3rem; }
.help { color: var(--muted); font-size: 13px; margin: .4rem 0 0; }
.banner { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.banner.warn { border-color: #7a5a14; background: #2b2110; color: #f6d98b; }
.banner.bad { border-color: #7a2a2a; background: #2c1214; color: #fca5a5; }
.banner.good { border-color: #1f6b3d; background: #10261a; color: #a7f3c4; }
.card > h2:first-child, .card > .row:first-child h2 { margin-top: 0; }

/* home */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: linear-gradient(120deg, #1d3346 0%, #16222d 55%, #18212a 100%); border: 1px solid #2c4256; border-radius: 18px; padding: 1.5rem 1.8rem; margin-bottom: 1.6rem; }
.hero h1 { font-size: 1.8rem; }
.hero .sub { margin: 0; }
.heroLogo { height: 70px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem; }
.tile { --app: var(--accent); position: relative; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.15rem 1.2rem 1rem; text-decoration: none; color: var(--text); overflow: hidden; transition: transform .15s, border-color .15s, box-shadow .15s; }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--app); }
.tile:hover { transform: translateY(-3px); border-color: var(--app); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.tilehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.tileicon { width: 46px; height: 46px; border-radius: 12px; background: var(--app); color: #fff; display: grid; place-items: center; }
.tileicon svg { width: 26px; height: 26px; }
.status { font-size: 12px; padding: .15rem .55rem; border-radius: 99px; border: 1px solid; }
.status.up { color: var(--good); border-color: #1f6b3d; background: #10261a; }
.status.down { color: var(--bad); border-color: #7a2a2a; background: #2c1214; }
.tile b { font-size: 1.15rem; margin-bottom: .3rem; }
.tile p { margin: 0 0 1rem; color: var(--muted); font-size: 14px; flex: 1; }
.tilefoot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: .7rem; }
.tile .role { font-size: 12px; color: var(--muted); }
.tile .open { font-weight: 600; color: var(--app); filter: brightness(1.35); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.qcard { display: flex; gap: .8rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; text-decoration: none; color: var(--text); }
.qcard:hover { border-color: var(--accent); }
.qcard .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--panel2); color: #9dd2ff; display: grid; place-items: center; flex: none; }
.qcard .ico svg { width: 19px; height: 19px; }
.qcard b { display: block; }
.qcard small { color: var(--muted); }

/* firewall log */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 0 0 1.1rem; }
.tabs a { padding: .55rem 1rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.logtitle { margin: 0; font-size: 1.15rem; }
.logtitle .muted { font-size: .85rem; font-weight: 400; }
.netrow { margin: .7rem 0 .2rem; gap: .4rem; }
.netchip, .nettag, .tpill { background: transparent; border: 1px solid; border-radius: 99px; font-size: 12px; font-weight: 600; padding: .1rem .55rem; }
.netchip { cursor: pointer; }
.nettag { display: inline-block; margin-top: .25rem; font-size: 11px; }
.tgt { display: inline-block; margin: 0 .5rem .25rem 0; white-space: nowrap; }
.groupchk { justify-content: flex-end; font-size: 13px; margin: .3rem 0 .4rem; }
.groupchk input { width: auto; }
table.fwlog td.small { font-size: 12px; white-space: nowrap; }
table.fwlog td.mono, table.fwlog td button, table.fwlog td .pill { white-space: nowrap; overflow-wrap: normal; }
table.fwlog td:last-child { width: 1%; }
table.fwlog tr.watchrow td { opacity: .75; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; font-size: 12px; padding: .08rem .55rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.good { color: var(--good); border-color: #1f6b3d; }
.pill.warn { color: var(--warn); border-color: #7a5a14; }
.pill.bad { color: var(--bad); border-color: #7a2a2a; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1000px 600px at 20% 0%, #1d3346 0%, transparent 60%), radial-gradient(800px 500px at 100% 100%, #0b2a33 0%, transparent 60%), var(--bg); }
.login form { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.8rem; display: grid; gap: .95rem; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.loginlogo { width: 220px; max-width: 80%; margin: 0 auto .2rem; display: block; }
.logintag { text-align: center; color: var(--muted); margin: 0 0 .3rem; }
.err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0; }

/* access editor */
.access { display: grid; gap: .45rem; }
.access .app { display: grid; grid-template-columns: auto 1fr 230px; gap: .6rem; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: rgb(5 3 10 / .7); display: grid; place-items: center; padding: 1rem; z-index: 10; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 660px; max-height: 92vh; overflow: auto; padding: 1.3rem 1.4rem; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #e8edf2; color: #10151b; padding: .65rem 1.05rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 20; }
#toast.show { opacity: 1; }
#toast.bad { background: #b91c1c; color: #fff; }
.qr { font-family: ui-monospace, monospace; word-break: break-all; background: var(--panel2); padding: .6rem; border-radius: 9px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 5; height: auto; max-height: 100vh; padding: .5rem .7rem; }
  .side .brandrow { width: 100%; }
  .side .brand { padding: .15rem .2rem; }
  .side .brand img { height: 34px; }
  .menubtn { display: inline-block; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; padding: .45rem .8rem; }
  .side > :not(.brandrow) { display: none; }
  .side.open > :not(.brandrow):not(.grow) { display: flex; }
  .side.open > .navhead, .side.open > .who { display: block; }
  .side.open { padding-bottom: 1rem; overflow-y: auto; }
  .side a { padding: .7rem .65rem; }
  .row > * { max-width: 100%; }
  .row > .grow { min-width: 0; flex-basis: 100%; }
  .row > select { width: 100%; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 1rem .9rem; }
  /* tables become one card per row, with each cell's column name in front of it */
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: .55rem 0; }
  td { border: 0; padding: .15rem 0; text-align: left !important; }
  td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  td:empty { display: none; }
  .modal { padding: 1rem; }
  .modal .actions { flex-wrap: wrap; }
  .hero h1 { font-size: 1.45rem; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 1rem; }
  .hero { flex-direction: column; align-items: flex-start; }
  .heroLogo { height: 52px; }
  .access .app { grid-template-columns: auto 1fr; }
  .access .app select { grid-column: 2; }
}
