/* Admin: a calm working tool in the brand colours (white surfaces, dark-green sidebar). */

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; color: var(--foreground); background: var(--neutral-100); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; margin: 0; }
.icon { width: 18px; height: 18px; flex: none; }
button { font: inherit; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; transition: background .2s, border-color .2s, color .2s; }
.btn.primary { background: var(--brand-700); color: #fff; }
.btn.primary:hover { background: var(--brand-800); }
.btn.ghost { background: #fff; border-color: var(--neutral-300); color: var(--brand-800); }
.btn.ghost:hover { border-color: var(--brand-500); }
.btn.danger { color: var(--destructive); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:focus-visible, .ib:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(0,160,90,.35); outline-offset: 1px; }
.btn.is-busy, .is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after, label.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-color: var(--green-500) transparent var(--green-500) transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ib { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--brand-700); cursor: pointer; }
.ib:hover { background: var(--neutral-100); }
.ib.danger { color: var(--destructive); }
.ib:disabled { opacity: .3; cursor: default; }

/* Fields */
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-weight: 600; font-size: 14px; color: var(--brand-800); }
.field .req { color: var(--destructive); font-style: normal; }
input, select, textarea { width: 100%; font: inherit; color: var(--foreground); background: #fff; border: 1px solid var(--neutral-300); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; line-height: 1.5; }
input[readonly] { background: var(--neutral-100); color: var(--muted-foreground); }
.is-invalid { border-color: var(--destructive) !important; }
.app-field-error { color: var(--destructive); font-size: 13px; font-weight: 600; }
.help { font-size: 13px; color: var(--muted-foreground); line-height: 1.4; margin: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 700px at 50% 0%, #d6e9d7 0%, var(--green-300) 45%, var(--green-400) 100%); }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 36px 32px; display: grid; gap: 16px; box-shadow: 0 30px 60px -30px rgba(18,37,35,.45); text-align: center; }
.login-card img { height: 64px; justify-self: center; }
.login-card h1 { font-size: 26px; margin-top: 8px; }
.login-card p { margin: 0 0 6px; color: var(--muted-foreground); line-height: 1.5; }
.login-card .field { text-align: left; }

/* Shell */
.adm { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 24px 16px; background: linear-gradient(180deg, var(--brand-800), var(--brand-900)); color: #dce8e6; overflow-y: auto; }
.side-logo { width: 100%; padding: 4px 8px 18px; filter: brightness(0) invert(1); }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--brand-400); padding: 14px 12px 6px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 600; }
.side-nav a:hover { background: rgba(187,217,189,.1); }
.side-nav a.on { background: var(--green-600); color: #fff; }
.side-nav .icon { color: var(--green-300); }
.side-nav a.on .icon { color: #fff; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 14px 8px 0; border-top: 1px solid rgba(162,172,171,.2); }
.side-foot > span { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.side-foot .btn { background: transparent; color: #dce8e6; border-color: rgba(162,172,171,.35); }

.main { padding: 32px 40px 120px; min-width: 0; display: grid; gap: 22px; align-content: start; }
.m-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.m-head h1 { font-size: 30px; }
.m-head p { margin: 6px 0 0; color: var(--muted-foreground); }
.m-body { display: grid; gap: 22px; }
.card { background: #fff; border: 1px solid var(--neutral-200); border-radius: 16px; padding: 24px; display: grid; gap: 18px; min-width: 0; }
.card.narrow { max-width: 480px; }
.card h2 { font-size: 19px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px 20px; }
.grid > .field.wide, .grid > .card, .grid > .list-card { grid-column: 1 / -1; }
.group .grid { gap: 16px 20px; }
.card .card { border-color: var(--neutral-200); background: var(--neutral-100); padding: 18px; }

/* Lists */
.list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.list-head .help { margin-top: 4px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); padding: 10px 12px; border-bottom: 1px solid var(--neutral-200); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--neutral-200); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: #f6faf7; }
.tbl .n { width: 40px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.tbl .acts { width: 1%; white-space: nowrap; text-align: right; }
.empty { padding: 26px; text-align: center; color: var(--muted-foreground); background: var(--neutral-100); border-radius: 12px; }
.datatable-top, .datatable-bottom { padding: 8px 0; }
.datatable-input { border-radius: 10px; }
.datatable-pagination .datatable-active a, .datatable-pagination .datatable-active button { background: var(--brand-700); color: #fff; }

/* Image field */
.img-field { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.img-prev { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; background: var(--neutral-100); display: grid; place-items: center; color: var(--brand-400); border: 1px solid var(--neutral-200); }
.img-prev img { width: 100%; height: 100%; object-fit: cover; }
.img-prev .icon { width: 30px; height: 30px; }
.img-acts { display: grid; gap: 8px; justify-items: start; }
.img-acts > div { display: flex; gap: 8px; }

/* Save bar */
.savebar { position: fixed; left: 270px; right: 0; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 14px 40px; background: rgba(255,255,255,.94); border-top: 1px solid var(--neutral-200); backdrop-filter: blur(8px); }
.savebar .hint { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; color: var(--muted-foreground); font-size: 14px; }
.savebar .unsaved { display: none; font-weight: 700; font-size: 14px; color: #9a6b00; }
.savebar.dirty .unsaved { display: inline; }

/* Settings */
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; }
.badge.ok { background: #e2f3e8; color: var(--accent); }
.badge.off { background: #fbe9ec; color: var(--destructive); }
.link-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--neutral-200); }
.link-row .li { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: #e2f3e8; color: var(--accent); }
.link-row .li .icon { width: 24px; height: 24px; }
.lt { display: grid; gap: 3px; min-width: 0; }
.lt span { color: var(--muted-foreground); font-size: 14px; }
.lt code { font-size: 13px; color: var(--brand-700); background: var(--neutral-100); padding: 4px 8px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; }
.la { display: flex; gap: 8px; flex-wrap: wrap; }
.key-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--neutral-200); flex-wrap: wrap; }
.key-row b { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; margin-left: 6px; }
.inline-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 280px; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted-foreground); padding: 40px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--green-500); border-right-color: transparent; animation: spin .8s linear infinite; }

/* Dialogs (shared helper markup) */
.app-dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px -30px rgba(18,37,35,.6); }
.app-dialog::backdrop { background: rgba(18,37,35,.5); }
.app-dialog-body { padding: 26px; display: grid; gap: 12px; }
.app-dialog-title { font-family: var(--font-heading); font-size: 21px; font-weight: 600; margin: 0; }
.app-dialog-text { margin: 0; color: var(--muted-foreground); line-height: 1.55; }
.app-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
.app-dialog-actions button { min-height: 42px; padding: 0 18px; border-radius: 10px; font-weight: 600; cursor: pointer; border: 1px solid var(--neutral-300); background: #fff; color: var(--brand-800); }
.app-dialog-actions .app-dialog-confirm { order: 2; background: var(--brand-700); color: #fff; border-color: var(--brand-700); }
.app-dialog.is-danger .app-dialog-confirm { background: var(--destructive); border-color: var(--destructive); }
.app-dialog.is-delete { border-top: 5px solid var(--destructive); }
.edit-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.edit-form { display: grid; grid-template-rows: auto 1fr auto; max-height: calc(100vh - 48px); }
.edit-form header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--neutral-200); }
.edit-form header h2 { font-size: 20px; }
.edit-body { padding: 22px 24px; overflow-y: auto; }
.edit-form footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--neutral-200); }

/* Toasts */
.app-toast { border-radius: 12px; font-weight: 600; box-shadow: 0 16px 40px -16px rgba(18,37,35,.5); color: #fff; background: var(--brand-800); }
.app-toast.is-success { background: var(--accent); }
.app-toast.is-error { background: var(--destructive); }

@media (max-width: 860px) {
    .adm { grid-template-columns: 1fr; }
    .side { position: static; height: auto; }
    .side-nav { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .main { padding: 20px 16px 120px; }
    .savebar { left: 0; padding: 12px 16px; flex-wrap: wrap; }
    .savebar .hint { display: none; }
    .link-row { grid-template-columns: 1fr; }
}
