/* ========================================================
   HERMES POS SHOP — Vintage Frontdesk / Touch-Friendly POS Theme
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=Lora:wght@400;500;600&display=swap');

:root {
    --parchment: #f5efe0;
    --cream: #faf6ed;
    --leather: #6b3a2a;
    --leather-dk: #4a2518;
    --brass: #c8a254;
    --brass-dk: #a07d2e;
    --ink: #2c1810;
    --ink-muted: #6d5d52;
    --line: rgba(44, 24, 16, 0.12);
    --success: #3d7a4a;
    --success-bg: rgba(61, 122, 74, 0.12);
    --error: #9f2d2d;
    --error-bg: rgba(159, 45, 45, 0.1);
    --warning: #b8860b;
    --warning-bg: rgba(184, 134, 11, 0.1);
    --shadow-sm: 0 2px 8px rgba(44, 24, 16, 0.08);
    --shadow: 0 8px 32px rgba(44, 24, 16, 0.12);
    --shadow-lg: 0 16px 48px rgba(44, 24, 16, 0.18);
    --radius: 16px;
    --radius-sm: 10px;
    --touch-min: 48px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    color: var(--ink);
    background:
        url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='none'/%3E%3Cpath d='M30 30m-1 0a1 1 0 1 0 2 0a1 1 0 1 0-2 0' fill='rgba(107,58,42,0.04)'/%3E%3C/svg%3E"),
        linear-gradient(170deg, #faf6ed 0%, #f0e8d4 40%, #e8dcc4 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--leather);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    color: var(--leather-dk);
}

/* --------------------------------------------------------
   TYPOGRAPHY
   -------------------------------------------------------- */
h1,
h2,
h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    color: var(--leather-dk);
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.35rem;
}

h3 {
    font-size: 1.1rem;
}

.eyebrow {
    font-family: 'Lora', serif;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.7rem;
    color: var(--brass-dk);
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* --------------------------------------------------------
   FORMS & INPUTS — Touch-friendly (min 48px targets)
   -------------------------------------------------------- */
button,
input,
select,
textarea {
    font: inherit;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: 999px;
    background: var(--leather);
    color: var(--cream);
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    -webkit-user-select: none;
    user-select: none;
}

button:hover,
.btn:hover {
    background: var(--leather-dk);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

button:active,
.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-brass {
    background: var(--brass);
    color: var(--ink);
}

.btn-brass:hover {
    background: var(--brass-dk);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--leather);
    color: var(--leather);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--leather);
    color: var(--cream);
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #2d6438;
}

.btn-danger {
    background: var(--error);
}

.btn-danger:hover {
    background: #7a2020;
}

.btn-sm {
    min-height: 44px;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
}

.btn-lg {
    min-height: 56px;
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    font-size: 1rem;
    color: var(--ink);
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(200, 162, 84, 0.2);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-height: auto;
    accent-color: var(--leather);
    cursor: pointer;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
    width: 22px;
    height: 22px;
}

/* --------------------------------------------------------
   LAYOUT — Sidebar shell
   -------------------------------------------------------- */
.page-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--leather-dk);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
    box-shadow: 2px 0 12px rgba(44, 24, 16, 0.22);
    z-index: 100;
    flex-shrink: 0;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar.collapsed {
    width: 62px;
    min-width: 62px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    position: relative;
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--brass);
    flex-shrink: 0;
    object-fit: cover;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-brand-text .brand-main {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cream);
    white-space: nowrap;
    letter-spacing: 0.08em;
}

.sidebar-brand-text .brand-sub {
    font-family: 'Playfair Display', serif;
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--brass);
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.sidebar-collapse-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--brass);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    min-height: unset;
    min-width: unset;
    border-radius: 4px;
    box-shadow: none;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: none;
    box-shadow: none;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .snav-label,
.sidebar.collapsed .snav-user-label {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.75rem 0;
}

.sidebar.collapsed .sidebar-collapse-btn {
    position: static;
    transform: none;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

/* Sidebar search */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0.75rem 0.2rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0.42rem 0.65rem;
    transition: border-color 0.15s, background 0.15s;
}

.sidebar-search:focus-within {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.35);
}

.sidebar-search-icon {
    font-size: 0.8rem;
    opacity: 0.6;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-search input {
    background: none !important;
    border: none !important;
    outline: none !important;
    color: #ffffff !important;
    font-size: 0.82rem;
    width: 100%;
    min-height: unset !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    font-family: inherit;
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.sidebar.collapsed .sidebar-search {
    display: none;
}

.snav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: #ffffff !important;
    font-size: 0.87rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
    margin: 0 0.4rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    position: relative;
    min-height: unset;
}

.snav-link:hover,
.snav-link:active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    text-decoration: none;
    transform: none;
    box-shadow: none;
}

.snav-link.active {
    background: rgba(0, 230, 118, 0.18);
    color: #00e676 !important;
    font-weight: 600;
}

.snav-icon {
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.snav-label {
    white-space: nowrap;
    overflow: hidden;
}

.snav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.4rem 0.85rem;
}

/* Collapsed tooltip */
.sidebar.collapsed .snav-link:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--leather-dk);
    color: var(--cream);
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
    z-index: 200;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.6rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    flex-shrink: 0;
}

.snav-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    color: var(--brass);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0.4rem;
}

.snav-user-label {
    white-space: nowrap;
    overflow: hidden;
}

.snav-user-label small {
    display: block;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: rgba(250, 246, 237, 0.5);
    font-size: 0.74rem;
}

.snav-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: #ffffff !important;
    font-size: 0.87rem;
    font-weight: 500;
    background: none !important;
    border: none !important;
    border-radius: 6px !important;
    margin: 0 0.4rem;
    cursor: pointer;
    text-align: left;
    width: calc(100% - 0.8rem);
    min-height: unset !important;
    min-width: unset !important;
    box-shadow: none !important;
    letter-spacing: 0;
    font-family: 'Lora', serif;
    transition: background 0.15s, color 0.15s;
}

.snav-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    transform: none !important;
    box-shadow: none !important;
}

.snav-lang {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    color: #ffffff !important;
    font-size: 0.87rem;
    margin: 0 0.4rem;
}

.snav-lang a {
    color: var(--brass);
    font-weight: 700;
    font-size: 0.82rem;
}

.snav-form {
    margin: 0 0.4rem;
}

.snav-form button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: #ffffff !important;
    font-size: 0.87rem;
    font-weight: 500;
    background: none !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer;
    width: 100%;
    min-height: unset !important;
    min-width: unset !important;
    box-shadow: none !important;
    letter-spacing: 0;
    font-family: 'Lora', serif;
    transition: background 0.15s, color 0.15s;
    justify-content: flex-start;
}

.snav-form button:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Nav section groups */
.snav-section-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem 0.2rem 0.9rem;
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    width: 100%;
    min-height: unset !important;
    min-width: unset !important;
    box-shadow: none !important;
    font-family: inherit;
    margin-top: 0.3rem;
    transition: color 0.15s;
}

.snav-section-header:hover {
    color: rgba(255, 255, 255, 0.7) !important;
    background: none !important;
    transform: none !important;
    box-shadow: none !important;
}

.snav-section-arrow {
    margin-left: auto;
    font-size: 0.85rem;
    line-height: 1;
    display: inline-block;
    transition: transform 0.2s ease;
}

.snav-section.open .snav-section-arrow {
    transform: rotate(90deg);
}

.snav-section-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}

.snav-section.open .snav-section-body {
    max-height: 500px;
}

.snav-section-body .snav-link {
    padding-left: 1.4rem;
}

/* Collapsed sidebar: flat icon-only view */
.sidebar.collapsed .snav-section-header {
    display: none;
}

.sidebar.collapsed .snav-section-body {
    max-height: none !important;
    overflow: visible;
}

.sidebar.collapsed .snav-section-body .snav-link {
    padding-left: 0.75rem;
}

/* Content area */
.content-wrap {
    flex: 1;
    min-width: 0;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    max-width: 1480px;
}

.content-wrap main {
    flex: 1;
}

/* Unauthenticated: no sidebar, full width */
.page-shell:not(.has-sidebar) .content-wrap {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--leather-dk), var(--leather));
    color: var(--cream);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(200, 162, 84, 0.15), transparent 70%);
    pointer-events: none;
}

.hero h1 {
    color: var(--cream);
    font-size: 1.5rem;
}

/* ── Header logo ─────────────────────────────────────── */
.hero-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.hero-logo {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid var(--brass);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

/* ── Admin dashboard hero ────────────────────────────── */
.admin-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.admin-hero-img {
    width: 90px;
    height: 90px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 2px solid var(--brass);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.hero .eyebrow {
    color: var(--brass);
}

.hero nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.hero nav a {
    color: var(--cream);
    padding: 0.55rem 1rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.2s;
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
}

.hero nav a:hover,
.hero nav a:active {
    background: rgba(255, 255, 255, 0.15);
}

.nav-user {
    color: var(--brass);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
}

.inline-form {
    display: inline-flex;
}

.inline-form button {
    font-size: 0.85rem;
    min-height: var(--touch-min);
    padding: 0.45rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    color: var(--cream);
}

.inline-form button:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --------------------------------------------------------
   FLASH MESSAGES
   -------------------------------------------------------- */
.flash-stack {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.flash {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    border-left: 4px solid;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

/* --------------------------------------------------------
   GRID LAYOUTS
   -------------------------------------------------------- */
.grid-layout,
.detail-grid {
    display: grid;
    gap: 1.25rem;
}

.grid-layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.9fr);
}

.detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid> :first-child {
    grid-column: 1 / -1;
}

/* --------------------------------------------------------
   PANELS (vintage card with brass top-line)
   -------------------------------------------------------- */
.panel {
    padding: 1.5rem;
    border: 1px solid rgba(107, 58, 42, 0.08);
    border-radius: var(--radius);
    background: var(--cream);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--leather), var(--brass), var(--leather));
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0.6;
}

.panel-heading,
.toolbar,
.action-row,
.action-row-spaced,
.two-up {
    display: flex;
    gap: 0.75rem;
}

.panel-heading,
.action-row-spaced {
    justify-content: space-between;
    align-items: center;
}

.panel-heading h2 {
    margin: 0;
}

.toolbar {
    flex-wrap: wrap;
    align-items: end;
    margin: 1rem 0 1.25rem;
    gap: 0.75rem;
}

/* Supplier filter bar */
.sup-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
}

.sup-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1 1 auto;
    min-width: 0;
    background: var(--parchment, var(--cream));
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
}

.sup-search-wrap input {
    background: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    min-height: unset !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    font-size: 0.82rem;
    color: var(--leather-dk);
}

.sup-search-icon {
    font-size: 0.75rem;
    opacity: 0.45;
    flex-shrink: 0;
}

.sup-filter-bar select {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 110px;
    max-width: 150px;
    min-height: unset !important;
    font-size: 0.82rem;
    padding: 0.3rem 0.5rem !important;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: var(--parchment, var(--cream));
    color: var(--leather-dk);
    cursor: pointer;
}

.sup-inline-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.sup-inline-form button {
    min-height: unset !important;
    min-width: unset !important;
    padding: 0.3rem 0.8rem !important;
    font-size: 0.82rem;
    border-radius: 6px;
}

.sup-count {
    font-size: 0.78rem;
    color: var(--leather);
    opacity: 0.65;
    white-space: nowrap;
    flex-shrink: 0;
}

.toolbar label,
.stack-form label {
    display: grid;
    gap: 0.35rem;
    color: var(--ink-muted);
    font-size: 0.88rem;
    font-weight: 500;
}

.search-field {
    flex: 1 1 200px;
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.login-shell {
    display: grid;
    place-items: center;
    min-height: 60vh;
}

.login-card {
    width: min(460px, 100%);
}

.two-up {
    align-items: end;
}

.two-up>* {
    flex: 1 1 0;
}

/* --------------------------------------------------------
   TABLES — Touch-sized rows
   -------------------------------------------------------- */
.table-wrap,
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.9rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--ink-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid rgba(107, 58, 42, 0.15);
}

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: rgba(200, 162, 84, 0.06);
}

.action-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

td .action-row button,
td .action-row .btn,
td .inline-form button,
td form button {
    min-height: 40px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
}

/* --------------------------------------------------------
   STATUS PILLS & BADGES
   -------------------------------------------------------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(107, 58, 42, 0.1);
    color: var(--leather);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-muted {
    background: rgba(109, 93, 82, 0.12);
    color: var(--ink-muted);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.empty-state {
    color: var(--ink-muted);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.mono-cell {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.88rem;
}

/* --------------------------------------------------------
   META & TOTALS GRIDS
   -------------------------------------------------------- */
.meta-grid,
.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.meta-grid dt,
.totals-grid dt {
    font-size: 0.78rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.meta-grid dd,
.totals-grid dd {
    font-size: 1.05rem;
    font-weight: 500;
}

.muted-note {
    color: var(--ink-muted);
    font-size: 0.88rem;
    font-style: italic;
}

/* --------------------------------------------------------
   GHOST LINK
   -------------------------------------------------------- */
.ghost-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 2px solid var(--leather);
    color: var(--leather);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.ghost-link:hover {
    background: var(--leather);
    color: var(--cream);
}

/* --------------------------------------------------------
   EDIT BUTTON
   -------------------------------------------------------- */
.edit-btn {
    border: 2px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    padding: 0.45rem 1rem;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.edit-btn:hover,
.edit-btn:active {
    background: var(--parchment);
    border-color: var(--brass);
}

/* --------------------------------------------------------
   PRINT RECORD
   -------------------------------------------------------- */
.print-record {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* --------------------------------------------------------
   COMPACT TABLE
   -------------------------------------------------------- */
.compact-table th,
.compact-table td {
    padding: 0.75rem 0.7rem;
    font-size: 0.9rem;
}

.text-success {
    color: var(--success);
    font-weight: 600;
}

.text-error {
    color: var(--error);
    font-weight: 600;
}

/* --------------------------------------------------------
   PRINT STYLES
   -------------------------------------------------------- */
@media print {
    body {
        background: #fff;
    }

    .hero,
    nav,
    button,
    .toolbar,
    .action-row,
    .action-row-spaced,
    .flash-stack,
    .ghost-link,
    .edit-btn {
        display: none !important;
    }

    .page-shell {
        padding: 0;
        max-width: 100%;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #999;
        break-inside: avoid;
    }

    .panel::after {
        display: none;
    }
}

/* --------------------------------------------------------
   RESPONSIVE — Touch device breakpoints
   -------------------------------------------------------- */
@media (max-width: 1024px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid> :first-child {
        grid-column: 1;
    }

    .hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .hero nav {
        width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .hero-logo {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .hero-brand {
        gap: 0.5rem;
    }

    .admin-hero {
        flex-direction: column;
        text-align: center;
    }

    .admin-hero-img {
        width: 70px;
        height: 70px;
    }

    .page-shell {
        padding: 1rem;
    }

    .panel {
        padding: 1rem;
    }

    th,
    td {
        padding: 0.85rem 0.6rem;
    }

    .toolbar {
        gap: 0.65rem;
        flex-wrap: wrap;
    }

    .two-up {
        flex-direction: column;
    }

    .meta-grid,
    .totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --------------------------------------------------------
   ADMIN DASHBOARD — Grid & Stat Cards
   -------------------------------------------------------- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.stat-card {
    text-align: center;
}

.stat-card h3 {
    margin-bottom: 0.75rem;
}

.stat-number {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3rem;
    font-weight: 800;
    color: var(--leather);
    line-height: 1.1;
    margin: 0.5rem 0 0.25rem;
}

.stat-card p {
    color: var(--ink-muted);
    font-size: 0.92rem;
    margin-bottom: 0.35rem;
}

.stat-card .btn {
    margin-top: 0.75rem;
    margin-right: 0.5rem;
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--leather);
    color: var(--leather);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--leather);
    color: var(--cream);
}

.btn-warn {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-warn:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.backup-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.text-warn {
    color: var(--warning);
    font-weight: 600;
}

.text-ok {
    color: var(--success);
    font-weight: 600;
}

.text-muted {
    color: var(--ink-muted);
    font-size: 0.88rem;
}

.team-summary {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    text-align: left;
}

.team-summary li {
    padding: 0.35rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --------------------------------------------------------
   ROLE BADGES
   -------------------------------------------------------- */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.role-admin {
    background: linear-gradient(135deg, var(--brass), var(--brass-dk));
    color: #fff;
}

.role-owner {
    background: linear-gradient(135deg, var(--brass), var(--brass-dk));
    color: #fff;
}

.role-frontdesk {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(61, 122, 74, 0.25);
}

.role-inventory_manager {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(184, 134, 11, 0.25);
}

.badge-active {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--success-bg);
    color: var(--success);
}

.badge-inactive {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--error-bg);
    color: var(--error);
}

.row-inactive {
    opacity: 0.55;
}

/* --------------------------------------------------------
   ADMIN FORMS
   -------------------------------------------------------- */
.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.form-group {
    display: grid;
    gap: 0.3rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-actions {
    display: flex;
    align-items: end;
}

.actions-cell {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.actions-cell select {
    min-height: var(--touch-min);
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    width: auto;
    min-width: 150px;
}

.btn-small {
    min-height: 44px;
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
}

@media (max-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .form-inline-grid {
        grid-template-columns: 1fr;
    }

    .actions-cell {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* --------------------------------------------------------
   INVITATIONS
   -------------------------------------------------------- */
.badge-pending {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--warning-bg);
    color: var(--warning);
}

.invite-link-input {
    width: 100%;
    min-width: 200px;
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
    min-height: 34px;
    cursor: pointer;
    background: var(--parchment);
    border: 1px dashed var(--brass);
}

/* --------------------------------------------------------
   NEW-ORDER MODAL
   -------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(44, 24, 16, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-dialog {
    background: var(--cream);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 960px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid var(--line);
    background: linear-gradient(135deg, var(--parchment), var(--cream));
}

.modal-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--ink-muted);
    cursor: pointer;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0.25rem;
    box-shadow: none;
    line-height: 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover,
.modal-close:active {
    color: var(--error);
    background: rgba(159, 45, 45, 0.08);
    box-shadow: none;
    transform: none;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

/* Product tile grid */
.product-grid {
    padding: 1.25rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    align-content: start;
}

.product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 100px;
    box-shadow: none;
    color: var(--ink);
    font-family: 'Lora', serif;
}

.product-card:hover {
    border-color: var(--brass);
    background: rgba(200, 162, 84, 0.12);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.product-card:active {
    transform: translateY(0);
    background: rgba(200, 162, 84, 0.22);
}

.product-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.product-card-price {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--leather);
}

.product-card-sku {
    font-size: 0.72rem;
    color: var(--ink-muted);
    margin-top: 0.25rem;
}

/* Cart sidebar */
.cart-panel {
    border-left: 2px solid var(--line);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--parchment);
}

.cart-panel h3 {
    font-family: 'Playfair Display', serif;
    margin: 0 0 0.75rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
}

.cart-line {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
}

.cart-line-name {
    font-weight: 500;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-line-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cart-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 1.2rem;
    border-radius: 50%;
    background: var(--leather);
    color: var(--cream);
    box-shadow: none;
}

.cart-btn:hover,
.cart-btn:active {
    background: var(--brass);
    box-shadow: none;
}

.cart-line-qty {
    font-weight: 700;
    min-width: 1.5em;
    text-align: center;
}

.cart-line-price {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: right;
    white-space: nowrap;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--brass);
    font-size: 1.1rem;
}

/* Modal footer / form */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid var(--line);
    background: var(--parchment);
}

.modal-form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-form-row label {
    flex: 1;
    display: grid;
    gap: 0.2rem;
}

.modal-form-row label span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ── Audit Log ───────────────────────────────────────────── */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.filter-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--brass);
    border-radius: 6px;
    background: var(--parchment);
    font-family: var(--ff-body);
    font-size: 0.9rem;
    min-width: 150px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (max-width: 700px) {
    .modal-body {
        grid-template-columns: 1fr;
    }

    .cart-panel {
        border-left: none;
        border-top: 2px solid var(--line);
        max-height: 220px;
    }

    .modal-form-row {
        flex-direction: column;
    }
}

/* ── Supplier & Purchase Order styles ────────────────── */

.row-selected {
    background: var(--accent-bg, rgba(184, 134, 11, 0.08));
}

.badge-info {
    background: rgba(30, 90, 160, 0.12);
    color: #1e5aa0;
}

.po-detail {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    margin: 0.75rem 0;
}

.po-detail dt {
    font-weight: 600;
    color: var(--leather, #5c3d2e);
}

.po-item-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border, #e0d5c1);
}

.po-item-row label {
    flex: 1;
    min-width: 120px;
}

.backup-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

details summary {
    cursor: pointer;
    user-select: none;
}

/* ============================================================
   DARK MODE — Royal Blue & Emerald Green
   ============================================================ */
[data-theme="dark"] {
    --parchment: #0f1923;
    --cream: #14202e;
    --leather: #4a7fc7;
    --leather-dk: #3566a8;
    --brass: #2ea870;
    --brass-dk: #24875a;
    --ink: #dce6f0;
    --ink-muted: #8a9bb2;
    --line: rgba(74, 127, 199, 0.15);
    --success: #2ea870;
    --success-bg: rgba(46, 168, 112, 0.14);
    --error: #d15454;
    --error-bg: rgba(209, 84, 84, 0.12);
    --warning: #d4a93a;
    --warning-bg: rgba(212, 169, 58, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] body {
    background:
        url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='none'/%3E%3Cpath d='M30 30m-1 0a1 1 0 1 0 2 0a1 1 0 1 0-2 0' fill='rgba(74,127,199,0.06)'/%3E%3C/svg%3E"),
        linear-gradient(170deg, #0f1923 0%, #121e2d 40%, #0d1720 100%);
}

[data-theme="dark"] a {
    color: var(--leather);
}

[data-theme="dark"] a:hover {
    color: #6ba0e0;
}

/* Hero header — deep royal blue gradient */
[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #0d1b2a, #1b3a5c);
    color: var(--ink);
}

[data-theme="dark"] .hero::before {
    background: radial-gradient(circle, rgba(46, 168, 112, 0.12), transparent 70%);
}

[data-theme="dark"] .hero .eyebrow {
    color: var(--brass);
}

[data-theme="dark"] .hero h1 {
    color: var(--ink);
}

[data-theme="dark"] .hero nav a {
    color: var(--ink);
}

[data-theme="dark"] .hero nav a:hover {
    background: rgba(74, 127, 199, 0.2);
}

[data-theme="dark"] .hero-logo {
    border-color: var(--brass);
}

[data-theme="dark"] .admin-hero-img {
    border-color: var(--brass);
}

[data-theme="dark"] .nav-user {
    color: var(--brass);
}

[data-theme="dark"] .inline-form button {
    background: rgba(74, 127, 199, 0.2);
    color: var(--ink);
}

[data-theme="dark"] .inline-form button:hover {
    background: rgba(74, 127, 199, 0.35);
}

/* Panels — dark card with royal blue/green top stripe */
[data-theme="dark"] .panel {
    background: var(--cream);
    border-color: rgba(74, 127, 199, 0.12);
}

[data-theme="dark"] .panel::after {
    background: linear-gradient(90deg, var(--leather), var(--brass), var(--leather));
    opacity: 0.7;
}

/* Inputs */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: rgba(14, 25, 38, 0.6);
    border-color: rgba(74, 127, 199, 0.2);
    color: var(--ink);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--leather);
    box-shadow: 0 0 0 3px rgba(74, 127, 199, 0.2);
}

[data-theme="dark"] input::placeholder {
    color: var(--ink-muted);
}

[data-theme="dark"] input[type="checkbox"] {
    accent-color: var(--brass);
}

/* Buttons */
[data-theme="dark"] button,
[data-theme="dark"] .btn {
    background: var(--leather);
    border-color: var(--leather);
    color: #fff;
}

[data-theme="dark"] button:hover,
[data-theme="dark"] .btn:hover {
    background: var(--leather-dk);
    border-color: var(--leather-dk);
}

[data-theme="dark"] .btn-success {
    background: var(--success);
    border-color: var(--success);
}

[data-theme="dark"] .btn-success:hover {
    background: #24875a;
    border-color: #24875a;
}

[data-theme="dark"] .btn-danger {
    background: var(--error);
    border-color: var(--error);
}

[data-theme="dark"] .btn-danger:hover {
    background: #b04040;
    border-color: #b04040;
}

[data-theme="dark"] .btn-secondary {
    background: transparent;
    border-color: var(--leather);
    color: var(--leather);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--leather);
    color: #fff;
}

[data-theme="dark"] .btn-warn {
    background: var(--warning);
    border-color: var(--warning);
}

/* Tables */
[data-theme="dark"] th {
    color: var(--ink-muted);
    border-bottom-color: rgba(74, 127, 199, 0.2);
}

[data-theme="dark"] td {
    border-bottom-color: rgba(74, 127, 199, 0.08);
}

[data-theme="dark"] tbody tr:hover {
    background: rgba(74, 127, 199, 0.08);
}

/* Ghost link & edit button */
[data-theme="dark"] .ghost-link {
    border-color: var(--leather);
    color: var(--leather);
}

[data-theme="dark"] .ghost-link:hover {
    background: var(--leather);
    color: #fff;
}

[data-theme="dark"] .edit-btn {
    background: rgba(20, 32, 46, 0.8);
    border-color: rgba(74, 127, 199, 0.2);
    color: var(--ink);
}

[data-theme="dark"] .edit-btn:hover {
    border-color: var(--brass);
    background: rgba(46, 168, 112, 0.1);
}

/* Stat numbers */
[data-theme="dark"] .stat-number {
    color: var(--leather);
}

/* Product cards */
[data-theme="dark"] .product-card {
    background: rgba(14, 25, 38, 0.5);
    border-color: rgba(74, 127, 199, 0.15);
    color: var(--ink);
}

[data-theme="dark"] .product-card:hover {
    border-color: var(--brass);
    background: rgba(46, 168, 112, 0.12);
}

[data-theme="dark"] .product-card:active {
    background: rgba(46, 168, 112, 0.22);
}

[data-theme="dark"] .product-card-price {
    color: var(--brass);
}

/* Cart */
[data-theme="dark"] .cart-panel {
    background: #0d1720;
    border-left-color: rgba(74, 127, 199, 0.15);
}

[data-theme="dark"] .cart-btn {
    background: var(--leather);
    color: #fff;
}

[data-theme="dark"] .cart-btn:hover {
    background: var(--brass);
}

[data-theme="dark"] .cart-total {
    border-top-color: var(--brass);
}

/* Modal */
[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] .modal-dialog {
    background: var(--cream);
}

[data-theme="dark"] .modal-header {
    background: linear-gradient(135deg, #0d1720, var(--cream));
    border-bottom-color: rgba(74, 127, 199, 0.15);
}

[data-theme="dark"] .modal-close:hover {
    color: var(--error);
}

[data-theme="dark"] .modal-footer {
    background: #0d1720;
    border-top-color: rgba(74, 127, 199, 0.15);
}

/* Print record */
[data-theme="dark"] .print-record {
    background: #0d1720;
    border-color: rgba(74, 127, 199, 0.15);
    color: var(--ink);
}

/* Invite link */
[data-theme="dark"] .invite-link-input {
    background: #0d1720;
    border-color: var(--brass);
    color: var(--ink);
}

/* Filter bar */
[data-theme="dark"] .filter-bar select {
    background: rgba(14, 25, 38, 0.6);
    border-color: var(--leather);
    color: var(--ink);
}

/* Badge info */
[data-theme="dark"] .badge-info {
    background: rgba(74, 127, 199, 0.15);
    color: var(--leather);
}

/* Row selected */
[data-theme="dark"] .row-selected {
    background: rgba(74, 127, 199, 0.1);
}

/* PO details */
[data-theme="dark"] .po-detail dt {
    color: var(--leather);
}

[data-theme="dark"] .po-item-row {
    border-bottom-color: rgba(74, 127, 199, 0.1);
}

/* --------------------------------------------------------
   THEME TOGGLE BUTTON
   -------------------------------------------------------- */
.theme-toggle {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--cream);
    cursor: pointer;
    border-radius: 999px;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0 0.5rem;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    box-shadow: none;
    line-height: 1;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: none;
    transform: none;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(74, 127, 199, 0.2);
    border-color: rgba(74, 127, 199, 0.3);
    color: var(--ink);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(74, 127, 199, 0.35);
}

/* ── Dark-mode contrast fixes ─────────────────────────── */

/* Headings: --leather-dk is too dark on dark backgrounds */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
    color: var(--ink);
}

/* Eyebrow labels need brighter green */
[data-theme="dark"] .eyebrow {
    color: var(--brass);
}

/* Btn outline / secondary hover text */
[data-theme="dark"] .btn-outline:hover {
    color: #fff;
}

[data-theme="dark"] .btn-secondary:hover {
    color: #fff;
}

/* Cart +/- buttons */
[data-theme="dark"] .cart-btn {
    color: #fff;
}

/* Label / span text inside toolbar and forms */
[data-theme="dark"] .toolbar label,
[data-theme="dark"] .stack-form label {
    color: var(--ink-muted);
}

[data-theme="dark"] .checkbox-field {
    color: var(--ink);
}

/* Muted note */
[data-theme="dark"] .muted-note {
    color: var(--ink-muted);
}

/* Status pill default */
[data-theme="dark"] .status-pill {
    background: rgba(74, 127, 199, 0.15);
    color: var(--leather);
}

/* Badge muted */
[data-theme="dark"] .badge-muted {
    background: rgba(138, 155, 178, 0.15);
    color: var(--ink-muted);
}

/* Empty state */
[data-theme="dark"] .empty-state {
    color: var(--ink-muted);
}

/* Meta / totals grids */
[data-theme="dark"] .meta-grid dt,
[data-theme="dark"] .totals-grid dt {
    color: var(--ink-muted);
}

/* Form group labels */
[data-theme="dark"] .form-group label {
    color: var(--ink-muted);
}

/* Text utility classes */
[data-theme="dark"] .text-muted {
    color: var(--ink-muted);
}

[data-theme="dark"] .text-warn {
    color: var(--warning);
}

[data-theme="dark"] .text-ok {
    color: var(--success);
}

/* Team summary list */
[data-theme="dark"] .team-summary li {
    border-bottom-color: rgba(74, 127, 199, 0.1);
}

/* Filter bar labels */
[data-theme="dark"] .filter-bar label {
    color: var(--ink-muted);
}

/* Modal form row labels */
[data-theme="dark"] .modal-form-row label span {
    color: var(--ink-muted);
}

/* Cart panel */
[data-theme="dark"] .cart-panel {
    background: #0b1118;
}

/* Product card SKU */
[data-theme="dark"] .product-card-sku {
    color: var(--ink-muted);
}

/* Modal footer */
[data-theme="dark"] .modal-footer {
    background: #0b1118;
}

/* Flash messages */
[data-theme="dark"] .flash-success {
    color: var(--success);
}

[data-theme="dark"] .flash-error {
    color: var(--error);
}

/* ========================================================
   TOUCHSCREEN PANEL SUPPORT
   ======================================================== */

/* Focus-visible outlines — keyboard & touch accessibility */
button:focus-visible,
.btn:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.edit-btn:focus-visible,
.cart-btn:focus-visible,
.product-card:focus-visible,
.theme-toggle:focus-visible,
.modal-close:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--brass);
    outline-offset: 2px;
}

/* Active / tap states mirror hover for touch feedback */
button:active,
.btn:active {
    background: var(--leather-dk);
    box-shadow: var(--shadow-sm);
    transform: translateY(0);
}

.btn-brass:active {
    background: var(--brass-dk);
    color: #fff;
}

.btn-outline:active {
    background: var(--leather);
    color: var(--cream);
}

.btn-success:active {
    background: #2d6438;
}

.btn-danger:active {
    background: #7a2020;
}

.product-card:active {
    transform: translateY(0);
    background: rgba(200, 162, 84, 0.22);
    border-color: var(--brass);
}

.hero nav a:active {
    background: rgba(255, 255, 255, 0.2);
}

.inline-form button:active {
    opacity: 0.85;
}

tbody tr:active {
    background: rgba(200, 162, 84, 0.1);
}

/* Summary / details touch target */
summary {
    min-height: var(--touch-min);
    padding: 0.5rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Checkbox touch area */
input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-height: 24px;
    cursor: pointer;
}

/* ── Touch-friendly spacing at tablet/mobile sizes ─────── */
@media (max-width: 1024px) {

    /* Action row buttons stack vertically */
    .action-row,
    .action-row-spaced {
        flex-direction: column;
        gap: 0.6rem;
        align-items: stretch;
    }

    .action-row>*,
    .action-row-spaced>* {
        width: 100%;
        justify-content: center;
    }

    /* Actions cell in tables */
    .actions-cell {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
}

@media (max-width: 768px) {

    /* Page padding */
    .page-shell {
        padding: 1rem;
    }

    /* Table cells need more padding for finger taps */
    th,
    td {
        padding: 0.85rem 0.6rem;
    }

    /* Larger font for readability on smaller panels */
    .hero nav a {
        padding: 0.6rem 1.1rem;
        font-size: 0.92rem;
    }

    .hero nav {
        gap: 0.4rem;
    }

    /* Cart grid goes vertical on tiny panels */
    .modal-body {
        grid-template-columns: 1fr;
    }

    .cart-panel {
        border-left: none;
        border-top: 2px solid var(--line);
        max-height: 40vh;
    }

    /* Product grid larger cards */
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.6rem;
    }

    /* Stack cart line for readability */
    .cart-line {
        gap: 0.4rem;
        padding: 0.65rem 0;
    }

    .cart-btn {
        min-height: var(--touch-min);
        min-width: var(--touch-min);
    }

    /* Toolbar wraps nicely */
    .toolbar {
        flex-wrap: wrap;
        gap: 0.65rem;
    }
}

/* Prevent text selection on interactive elements (touch panels) */
button,
.btn,
.edit-btn,
.cart-btn,
.product-card,
.theme-toggle,
.hero nav a {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Dark mode focus ring */
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] .btn:focus-visible,
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] textarea:focus-visible,
[data-theme="dark"] .edit-btn:focus-visible,
[data-theme="dark"] .cart-btn:focus-visible,
[data-theme="dark"] .product-card:focus-visible,
[data-theme="dark"] .theme-toggle:focus-visible,
[data-theme="dark"] .modal-close:focus-visible,
[data-theme="dark"] summary:focus-visible {
    outline-color: var(--leather);
}

/* ========================================================
   MOBILE GATE — blocks non-admin roles on small screens
   ======================================================== */
.mobile-gate {
    display: none;
}

@media (max-width: 768px) {
    .mobile-gate {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 99999;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        background:
            url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='none'/%3E%3Cpath d='M30 30m-1 0a1 1 0 1 0 2 0a1 1 0 1 0-2 0' fill='rgba(107,58,42,0.04)'/%3E%3C/svg%3E"),
            linear-gradient(170deg, #faf6ed 0%, #f0e8d4 40%, #e8dcc4 100%);
    }

    .mobile-gate-card {
        text-align: center;
        background: var(--cream);
        padding: 2.5rem 2rem;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        max-width: 360px;
        border: 2px solid var(--line);
    }

    .mobile-gate-card h2 {
        font-family: 'Playfair Display', Georgia, serif;
        color: var(--leather);
        font-size: 1.6rem;
        margin: 0.75rem 0;
    }

    .mobile-gate-card p {
        color: var(--ink-muted);
        line-height: 1.6;
        font-size: 0.95rem;
    }

    .mobile-gate-card .btn {
        margin-top: 0.5rem;
    }
}

/* Dark mode gate */
[data-theme="dark"] .mobile-gate {
    background: linear-gradient(170deg, #181818 0%, #1e1e1e 40%, #222 100%);
}

[data-theme="dark"] .mobile-gate-card {
    background: #232323;
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .mobile-gate-card h2 {
    color: #e0e0e0;
}

[data-theme="dark"] .mobile-gate-card p {
    color: #aaa;
}

/* ========================================================
   ADMIN MOBILE — responsive admin dashboard on phones
   ======================================================== */
@media (max-width: 768px) {

    /* Nav wraps as a compact pill grid */
    body[data-role="admin"] .hero nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        overflow-x: visible;
    }

    body[data-role="admin"] .hero nav a {
        font-size: 0.78rem;
        padding: 0.4rem 0.65rem;
        min-height: 36px;
        white-space: nowrap;
    }

    body[data-role="admin"] .hero h1 {
        font-size: 1.3rem;
    }

    body[data-role="admin"] .hero .eyebrow {
        font-size: 0.7rem;
    }

    /* Stat cards compact for mobile */
    .stat-card {
        padding: 1.25rem;
    }

    .stat-number {
        font-size: 2.2rem;
    }

    .stat-card .btn {
        font-size: 0.82rem;
        padding: 0.45rem 0.8rem;
    }

    /* Team summary list more compact */
    .team-summary li {
        font-size: 0.82rem;
        gap: 0.3rem;
        flex-wrap: wrap;
    }

    .role-badge {
        font-size: 0.68rem;
        padding: 0.15rem 0.45rem;
    }

    /* Horizontal-scroll wrapper for wide tables */
    .table-wrap table,
    .table-wrapper table {
        min-width: 600px;
    }

    /* Invite link narrower */
    .invite-link-input {
        min-width: 0;
        max-width: 180px;
        font-size: 0.7rem;
    }

    /* Backup actions stack */
    .backup-actions {
        flex-direction: column;
        align-items: stretch;
    }

    /* Audit log filter bar stacks */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar select {
        width: 100%;
        min-width: 0;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar select,
    .toolbar input {
        width: 100%;
    }

    /* Nav user info compact */
    .nav-user {
        font-size: 0.75rem;
        order: 99;
        width: 100%;
        text-align: center;
        padding: 0.3rem 0;
        border-top: 1px solid var(--line);
        margin-top: 0.25rem;
    }
}

@media (max-width: 480px) {

    /* Very small phones: tighter layout */
    body[data-role="admin"] .hero nav a {
        font-size: 0.72rem;
        padding: 0.35rem 0.55rem;
    }

    body[data-role="admin"] .page-shell {
        padding: 0.65rem;
    }

    .stat-number {
        font-size: 1.8rem;
    }

    .admin-grid {
        gap: 0.75rem;
    }
}