/* Aquarium Zone mail admin — follows the aquariumzone.com.au design language:
   ink/cream palette, square corners, heavy tight headings, tracked uppercase labels. */
:root {
    --ink: #09151C;
    --ink-2: #13242D;
    --cream: #F1F2ED;
    --sage: #E9EDE3;
    --mist: #E7EBE8;
    --paper: #FFFFFF;
    --line: #D6DCD5;
    --muted: #49595F;
    --muted-2: #6B7A80;
    --label: #007BAD;
    --sky: #7DD3FC;
    --blue: #0076A5;
    --leaf: #3B6146;
    --danger: #B42318;
    --ok: #2F6B3A;
    --warn: #9A6700;
    --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    background: var(--cream);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 28px;
    padding: 0 24px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand span {
    font-size: 11px; font-weight: 750; letter-spacing: .2em; text-transform: uppercase;
    color: var(--label); border-left: 1px solid var(--line); padding-left: 12px;
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
    text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted);
    padding: 8px 14px; border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.topbar .spacer { flex: 1; }

/* ---------- Page ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 40px 24px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 32px; }
.eyebrow {
    margin: 0 0 10px; font-size: 11.2px; font-weight: 750; letter-spacing: .2em;
    text-transform: uppercase; color: var(--label);
}
h1, .h1 { margin: 0; font-size: 40px; line-height: 1.02; font-weight: 800; letter-spacing: -.045em; }
h2, .h2 { margin: 0; font-size: 24px; line-height: 1.1; font-weight: 780; letter-spacing: -.035em; }
h3 { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.lede { margin: 12px 0 0; color: var(--muted); max-width: 60ch; line-height: 1.7; }
.muted { color: var(--muted-2); }
.small { font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border: 1px solid var(--ink); border-radius: 0;
    background: var(--ink); color: #fff;
    font: 650 14px/1.2 var(--font); text-decoration: none; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--ink-2); }
.btn .arrow { font-weight: 700; }
.btn-outline { background: transparent; color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: #fff; }
.btn-sky { background: var(--sky); border-color: var(--sky); color: var(--ink); }
.btn-sky:hover { background: #a5e1fd; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 8px 10px; }
.btn-ghost:hover { background: var(--mist); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Panels & cards ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); padding: 24px; }
.panel + .panel { margin-top: 20px; }
.panel-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.panel-dark .eyebrow { color: var(--sky); }
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 32px; }
.stat { background: var(--paper); padding: 20px 22px; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.stat .label { font-size: 11px; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; color: var(--muted-2); margin-top: 6px; }

.template-card { background: var(--paper); border: 1px solid var(--line); display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.template-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.template-thumb { position: relative; height: 260px; overflow: hidden; background: var(--mist); border-bottom: 1px solid var(--line); }
.template-thumb iframe { width: 640px; height: 1200px; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; background: #fff; }
.template-thumb .empty { display: grid; place-items: center; height: 100%; color: var(--muted-2); font-size: 13px; }
.template-thumb a.cover { position: absolute; inset: 0; }
.template-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.template-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; }

.badge {
    display: inline-block; padding: 3px 8px; font-size: 10.5px; font-weight: 750;
    letter-spacing: .14em; text-transform: uppercase; border: 1px solid currentColor;
}
.badge-sky { color: var(--label); }
.badge-ok { color: var(--ok); }
.badge-warn { color: var(--warn); }
.badge-danger { color: var(--danger); }
.badge-muted { color: var(--muted-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; font-size: 10.5px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase;
    color: var(--muted-2); padding: 14px 16px; border-bottom: 1px solid var(--line); background: #FAFBF8;
}
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--mist); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #FAFBF8; }

.progress { height: 6px; background: var(--mist); position: relative; min-width: 120px; }
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--blue); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .label {
    font-size: 11px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.field .hint { font-size: 12.5px; color: var(--muted-2); }
input:not([type]), input[type=tel], input[type=password], input[type=time], input[type=text], input[type=email], input[type=url], input[type=number], input[type=search], select, textarea {
    width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 0;
    background: #fff; color: var(--ink); font: 14px/1.4 var(--font);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: -1px; border-color: var(--ink); }
textarea { resize: vertical; min-height: 90px; }
.radio-cards { display: grid; gap: 10px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.radio-card input { margin-top: 3px; accent-color: var(--ink); }
.radio-card strong { display: block; font-size: 14px; }
.radio-card span { font-size: 13px; color: var(--muted-2); }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--ink); padding: 0; max-width: 560px; width: calc(100% - 32px); border-radius: 0; color: var(--ink); }
dialog.wide { max-width: 960px; }
dialog::backdrop { background: rgba(9, 21, 28, .55); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 24px; max-height: 70vh; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); background: #FAFBF8; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 1000; max-width: 420px;
    padding: 14px 18px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
    border-left: 4px solid var(--sky); opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: #F97066; }

.notice { padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--blue); background: #fff; font-size: 14px; margin-bottom: 20px; }
.notice.warn { border-left-color: var(--warn); }
.notice.danger { border-left-color: var(--danger); }
.notice code, .panel code { background: var(--mist); padding: 1px 6px; font-size: 13px; }
pre.code { background: var(--ink); color: #DDE7EB; padding: 14px 16px; overflow-x: auto; font-size: 13px; margin: 8px 0 0; }

.empty-state { text-align: center; padding: 64px 24px; background: var(--paper); border: 1px dashed var(--line); }

@media (max-width: 720px) {
    .topbar { gap: 12px; padding: 0 16px; overflow-x: auto; }
    .brand span { display: none; }
    .page { padding: 28px 16px 64px; }
    h1, .h1 { font-size: 32px; }
}

/* =========================================================== AquaCentral shell */
:root { --sidebar-w: 248px; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-name em { font-style: normal; font-weight: 600; color: var(--sky); }
.topbar .brand-name em { color: var(--label); }
.ico { width: 18px; height: 18px; flex-shrink: 0; }

body.has-sidebar .app-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 70;
    background: var(--ink); color: #C9D6DB; display: flex; flex-direction: column;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.nav-label { margin: 18px 10px 6px; font-size: 10px; font-weight: 750; letter-spacing: .2em; text-transform: uppercase; color: #6E8790; }
.side-nav a {
    display: flex; align-items: center; gap: 11px; padding: 9px 10px; margin: 1px 0;
    color: #C9D6DB; text-decoration: none; font-size: 14px; font-weight: 550; border-left: 2px solid transparent;
}
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(125,211,252,.12); color: #fff; border-left-color: var(--sky); }
.side-nav a.active .ico { color: var(--sky); }
.side-nav .pill { margin-left: auto; background: var(--sky); color: var(--ink); font-size: 11px; padding: 1px 7px; font-weight: 800; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user-name { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-decoration: none; color: #fff; }
.side-user-name strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-name small { display: block; font-size: 11.5px; color: #8FA6AE; }
.side-user-name > span:last-child { min-width: 0; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; background: var(--sky); color: var(--ink); font-weight: 800; flex-shrink: 0; }
.icon-btn { background: none; border: 0; color: inherit; padding: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.side-user form { margin: 0; }
.mobile-bar, .scrim { display: none; }

@media (max-width: 960px) {
    body.has-sidebar .app-main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(9,21,28,.5); z-index: 60; }
    .mobile-bar { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 10px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; }
}

/* ---------- Shared page bits ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 340px; }
.toolbar select { width: auto; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 12px; font-weight: 650; background: var(--mist); color: var(--ink); margin: 2px 4px 2px 0; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: var(--muted-2); font-size: 14px; line-height: 1; }
.yes { color: var(--ok); font-weight: 700; }
.no { color: var(--muted-2); }
.pager { display: flex; gap: 6px; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; color: var(--muted-2); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--mist); font-size: 14px; display: flex; gap: 12px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted-2); font-size: 12.5px; white-space: nowrap; min-width: 120px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.switch input { width: 36px; height: 20px; appearance: none; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(16px); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.spark span { flex: 1; background: var(--blue); min-height: 2px; position: relative; }
.spark span:hover { background: var(--ink); }
.bar-list { list-style: none; margin: 0; padding: 0; }
.bar-list li { position: relative; padding: 8px 10px; font-size: 13.5px; display: flex; justify-content: space-between; gap: 10px; }
.bar-list li::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); background: rgba(0,118,165,.10); }
.bar-list li > * { position: relative; }
.bar-list .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .brand-name { border: 0; padding: 0; text-transform: none; letter-spacing: -.02em; font-size: 15px; font-weight: 800; color: inherit; }
.sidebar .brand img { height: 26px; width: auto; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

[hidden] { display: none !important; }

/* Segmented toggle (shared) */
.device-toggle { display: inline-flex; border: 1px solid var(--line); background: #fff; }
.device-toggle > a, .device-toggle > button { text-decoration: none; display: flex; }
.device-toggle button { border: 0; background: #fff; padding: 8px 14px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; }
.device-toggle > * + * { border-left: 1px solid var(--line); }
.device-toggle button.active { background: var(--ink); color: #fff; }
.device-toggle button:hover:not(.active) { color: var(--ink); background: var(--cream); }
