*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --muted: #64748b;
    --text: #0f172a;
    --line: #dbe4f0;
    --accent: #2563eb;
    --accent-soft: #e8f0ff;
    --danger: #dc2626;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: linear-gradient(180deg, #eff5ff 0%, var(--bg) 180px, var(--bg) 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
textarea,
select {
    font: inherit;
}

.site-shell,
.admin-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: var(--card);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-bar,
.admin-header {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    margin-bottom: 22px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 18px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

h1, h2, h3, h4 {
    margin: 0 0 8px;
    line-height: 1.1;
}

p {
    margin: 0;
}

.hero-copy,
.muted,
.hint,
.small {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.hero-actions,
.admin-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-wrap {
    min-width: min(360px, 100%);
}

.search-wrap input,
.table-filter,
input[type="text"],
input[type="password"],
input[type="search"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(0.98);
}

.btn-soft {
    background: #eef3fb;
    color: var(--text);
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-small {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.user-chip,
.pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.group-logo-wrap,
.print-logo-block,
.print-logo-centered {
    display: flex;
    justify-content: center;
    align-items: center;
}

.group-logo,
.store-inline-logo,
.print-store-logo,
.placeholder-logo {
    border-radius: 18px;
    object-fit: contain;
    background: #f8fbff;
    border: 1px solid #d8e2f0;
}

.group-logo,
.placeholder-logo {
    width: 88px;
    height: 88px;
}

.store-inline-logo {
    width: 84px;
    height: 84px;
    margin: 0 auto;
}

.print-store-logo {
    width: 150px;
    height: 150px;
    margin: 0 auto 14px;
}

.placeholder-logo {
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 800;
    color: var(--accent);
}

.store-list {
    display: grid;
    gap: 18px;
}

.store-card {
    overflow: hidden;
}

.store-summary {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 20px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    cursor: pointer;
}

.store-summary-main {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.store-brand-chip {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.store-business-card h2 {
    font-size: 22px;
    margin-bottom: 6px;
}

.store-micro {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.accordion-indicator {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.store-card.open .accordion-indicator::after {
    content: " (open)";
}

.store-detail {
    display: none;
    padding: 0 22px 22px;
    border-top: 1px solid #edf2f7;
}

.store-card.open .store-detail {
    display: block;
}

.store-top-grid {
    display: grid;
    grid-template-columns: 1.8fr 0.8fr;
    gap: 18px;
    padding-top: 18px;
}

.store-profile,
.store-utility-panel,
.advanced-card,
.sidebar-card,
.empty-state {
    padding: 18px;
    border-radius: var(--radius-sm);
    background: #fafcff;
    border: 1px solid #e4edf7;
}

.compact-info-grid,
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 12px 18px;
    margin-top: 16px;
}

.compact-info-grid div,
.info-grid div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.full-span {
    grid-column: 1 / -1;
}

.label,
.label-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mini-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 10px;
}

.directory-sections {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.dept-section {
    border: 1px solid #e7eef8;
    border-radius: 16px;
    padding: 16px;
    background: #fff;
}

.dept-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.phone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
    gap: 12px;
}

.phone-card {
    background: #f8fbff;
    border: 1px solid #e2ebf5;
    border-radius: 14px;
    padding: 14px;
}

.phone-topline {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.phone-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: #1e293b;
    font-size: 14px;
}

.phone-note {
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
    border-top: 1px dashed #dbe6f1;
    padding-top: 10px;
}

.dept-badge {
    background: #eff6ff;
    color: #1d4ed8;
}

.advanced-only {
    display: none;
    margin-top: 18px;
}

body.advanced-on .advanced-only {
    display: block;
}

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 16px;
}

.simple-list {
    display: grid;
    gap: 10px;
}

.simple-list-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e5edf7;
    border-radius: 12px;
    background: #fff;
}

.right-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.subheading {
    margin-top: 18px;
    margin-bottom: 10px;
    color: #334155;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f8fbff;
    border: 1px solid #dbe7f3;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    color: #334155;
}

.toggle-pill input {
    width: auto;
    margin: 0;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) 360px;
    gap: 20px;
}

.admin-main {
    display: grid;
    gap: 20px;
}

.admin-section {
    padding: 20px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.sticky-tools {
    position: sticky;
    top: 10px;
    z-index: 5;
    background: #fff;
    padding-bottom: 10px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 14px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.stack-form label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: #334155;
}

.checkbox-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dbe7f3;
    background: #fff;
    padding: 10px 12px;
    border-radius: 999px;
}

.listing-stack {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.admin-item-card {
    border: 1px solid #e5edf7;
    border-radius: 16px;
    background: #fbfdff;
}

.admin-item-card summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.admin-item-card summary::-webkit-details-marker {
    display: none;
}

.details-body {
    padding: 0 16px 16px;
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid #e5edf7;
    border-radius: 16px;
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}

.data-table.compact {
    min-width: 1180px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fbff;
    border-bottom: 1px solid #dbe7f3;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-align: left;
    padding: 12px;
}

.data-table td {
    border-bottom: 1px solid #eef4fa;
    padding: 10px 12px;
    vertical-align: top;
}

.data-table td input,
.data-table td select {
    min-width: 100px;
    padding: 9px 10px;
}

.row-actions {
    white-space: nowrap;
}

.text-link {
    color: var(--accent);
    font-weight: 700;
}

.danger-link {
    color: var(--danger);
    margin-left: 8px;
}

.stats-list {
    display: grid;
    gap: 12px;
}

.stats-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    background: #f8fbff;
    border: 1px solid #e2ebf5;
}

.log-list {
    display: grid;
    gap: 12px;
    max-height: 900px;
    overflow: auto;
}

.log-item {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #e7eef8;
    background: #fbfdff;
}

.log-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.log-details summary {
    cursor: pointer;
    margin-top: 10px;
    font-weight: 700;
}

.log-json {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.log-json pre {
    margin: 6px 0 0;
    padding: 12px;
    border-radius: 12px;
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
    font-size: 12px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
    display: grid;
    gap: 14px;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 12px 14px;
}

.print-toolbar {
    padding: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.print-sheet {
    width: min(1100px, calc(100% - 30px));
    margin: 0 auto 40px;
    background: #fff;
    border-radius: 18px;
    padding: 34px;
    box-shadow: var(--shadow);
}

.centered-header {
    text-align: center;
    border-bottom: 2px solid #dbe7f3;
    padding-bottom: 22px;
    margin-bottom: 24px;
}

.print-header h1 {
    font-size: 34px;
    margin-bottom: 8px;
}

.print-subline {
    color: var(--accent);
    font-weight: 800;
    margin-bottom: 12px;
}

.print-meta {
    display: flex;
    gap: 10px 18px;
    justify-content: center;
    flex-wrap: wrap;
    color: #334155;
    font-size: 14px;
}

.print-directory-grid {
    display: grid;
    gap: 18px;
}

.print-dept-card {
    border: 1px solid #dbe7f3;
    border-radius: 16px;
    padding: 16px;
    page-break-inside: avoid;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
}

.print-table th,
.print-table td {
    text-align: left;
    border-bottom: 1px solid #e5edf7;
    padding: 10px 8px;
    font-size: 14px;
}

.hidden-by-search {
    display: none !important;
}

@media (max-width: 1100px) {
    .admin-grid,
    .store-top-grid,
    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .hero-bar,
    .admin-header,
    .brand-lockup {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrap {
        min-width: 0;
    }
}

@media (max-width: 700px) {
    .site-shell,
    .admin-shell {
        padding: 14px;
    }

    .hero-bar,
    .admin-header,
    .admin-section {
        padding: 16px;
    }

    .store-summary {
        padding: 16px;
    }

    .store-summary-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .compact-info-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .phone-grid {
        grid-template-columns: 1fr;
    }

    .print-sheet {
        width: calc(100% - 20px);
        padding: 18px;
    }
}

@media print {
    html, body {
        background: #fff;
    }

    .no-print,
    .hero-bar,
    .admin-header,
    .admin-shell,
    .admin-page,
    .btn,
    .store-utility-panel,
    .toggle-pill {
        display: none !important;
    }

    .print-sheet {
        width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .print-dept-card {
        break-inside: avoid;
    }

    @page {
        margin: 0.45in;
        size: auto;
    }
}
