* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f4f6f9; color: #1a2332; font-size: 14px; }
a { color: #7b2cbf; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout: fixed left sidebar + scrollable page ---- */
.layout { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar { width: 232px; flex-shrink: 0; background: #fff; border-right: 1px solid #e8eaf0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,#7b2cbf,#9d4edd); color: #fff; font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 17px; font-weight: 700; color: #1a2332; }

.shop-card { display: flex; align-items: center; gap: 10px; margin: 0 14px 12px; padding: 8px 10px; border: 1px solid #e8eaf0; border-radius: 12px; background: #fafafe; }
.shop-card-ico { width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; background: linear-gradient(135deg,#7b2cbf,#9d4edd); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.shop-card select { flex: 1; min-width: 0; border: none; background: transparent; font-size: 13px; font-weight: 600; color: #1a2332; cursor: pointer; padding: 2px 0; }
.shop-card select:focus { outline: none; }

.tabs { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; overflow-y: auto; flex: 1; }
.tab { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #5a6473; font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap; }
.tab .tab-ico { flex-shrink: 0; color: #9aa3b2; }
.tab:hover:not(.active) { background: #f4f5f9; color: #1a2332; text-decoration: none; }
.tab:hover:not(.active) .tab-ico { color: #5a6473; }
.tab.active { background: #f1e9fb; color: #7b2cbf; font-weight: 600; }
.tab.active .tab-ico { color: #7b2cbf; }

.sidebar-footer { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; border-top: 1px solid #e8eaf0; }
.sidebar-footer button { flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid #e0e4ea; background: #fff; color: #5a6473; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.sidebar-footer button:hover { background: #f4f5f9; color: #1a2332; }
.sidebar-footer button.logout { flex-basis: 100%; }
.sidebar-footer button.logout:hover { background: #fdecee; color: #b02a37; border-color: #f3c2c8; }

.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e8eaf0; padding: 16px 28px; }
.topbar h1 { font-size: 22px; font-weight: 700; color: #1a2332; }

.content { padding: 24px 28px; flex: 1; min-width: 0; }

.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px; }
.card h2 { font-size: 16px; margin-bottom: 12px; color: #1a2332; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input, .filters select { padding: 6px 10px; border: 1px solid #d0d4da; border-radius: 6px; font-size: 13px; }
.filters button { padding: 6px 14px; background: #7b2cbf; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
.filters button:hover { background: #6420a0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef1f5; vertical-align: top; }
th { background: #f8f9fb; font-weight: 600; color: #556; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tr:hover td { background: #fafbfd; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f0ebf8; }

.muted { color: #889; font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eef; color: #447; }
.badge.green { background: #d4edda; color: #1e7e34; }
.badge.red { background: #f8d7da; color: #b02a37; }
.badge.yellow { background: #fff3cd; color: #856404; }

.err { background: #f8d7da; color: #b02a37; padding: 12px 16px; border-radius: 6px; margin-bottom: 12px; }
.ok { background: #d4edda; color: #155724; padding: 12px 16px; border-radius: 6px; }
.loading { color: #667; padding: 20px; text-align: center; }

.modal { position: fixed; inset: 0; background: rgba(20,30,50,.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-box { background: #fff; padding: 28px; border-radius: 10px; width: 440px; max-width: 92vw; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.modal-box h2 { font-size: 18px; margin-bottom: 8px; }
.modal-box p { color: #667; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.modal-box input { width: 100%; padding: 10px 12px; border: 1px solid #d0d4da; border-radius: 6px; font-size: 14px; margin-bottom: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.modal-box button { width: 100%; padding: 10px; background: #7b2cbf; color: #fff; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
.modal-box button:hover { background: #6420a0; }

.pagination { display: flex; gap: 6px; align-items: center; margin-top: 12px; justify-content: flex-end; }
.pagination button { padding: 4px 10px; border: 1px solid #d0d4da; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .label { font-size: 12px; color: #889; text-transform: uppercase; letter-spacing: .3px; }
.stat .value { font-size: 22px; font-weight: 700; color: #1a2332; margin-top: 4px; }

code { background: #f4f6f9; padding: 1px 6px; border-radius: 3px; font-size: 12px; }
.raw { max-height: 400px; overflow: auto; background: #1a2332; color: #d4d4d4; padding: 12px; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; }

.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid #e0e4ea; padding-bottom: 8px; }
.subtab { padding: 6px 12px; cursor: pointer; border-radius: 16px; font-size: 12px; color: #556; background: #f4f6f9; border: 1px solid transparent; }
.subtab:hover { background: #e9ecf1; }
.subtab.active { background: #1a2332; color: #fff; border-color: #1a2332; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 80%; max-width: 1100px; background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.15); z-index: 200; overflow-y: auto; transform: translateX(100%); transition: transform .2s ease; }
.drawer.open { transform: translateX(0); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(20,30,50,.5); z-index: 199; display: none; }
.drawer-overlay.open { display: block; }
.drawer-head { padding: 16px 24px; border-bottom: 1px solid #e0e4ea; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: #fff; z-index: 1; }
.drawer-head h2 { font-size: 18px; flex: 1; }
.drawer-head .close { background: none; border: none; font-size: 24px; cursor: pointer; color: #556; padding: 0 8px; }
.drawer-body { padding: 20px 24px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin-bottom: 16px; font-size: 13px; }
.kv dt { color: #889; }
.kv dd { color: #1a2332; }
.section-h { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: #445; text-transform: uppercase; letter-spacing: .3px; }

.btn { padding: 8px 14px; background: #7b2cbf; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; display: inline-block; text-decoration: none; }
.btn:hover { background: #6420a0; text-decoration: none; color: #fff; }
.btn.outline { background: #fff; color: #7b2cbf; border: 1px solid #7b2cbf; }
.btn.outline:hover { background: #f4ebf9; color: #7b2cbf; }
.btn.ghost { background: #f4f6f9; color: #445; border: 1px solid #d0d4da; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.edit-modal { position: fixed; inset: 0; background: rgba(20,30,50,.5); display: flex; align-items: center; justify-content: center; z-index: 300; }
.edit-modal.hidden { display: none; }
.edit-modal .box { background: #fff; padding: 24px; border-radius: 10px; width: 480px; max-width: 94vw; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.edit-modal h2 { font-size: 16px; margin-bottom: 4px; }
.edit-modal .sub { color: #889; font-size: 12px; margin-bottom: 16px; }
.edit-modal .row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.edit-modal label { color: #445; font-size: 13px; }
.edit-modal input { padding: 8px 10px; border: 1px solid #d0d4da; border-radius: 6px; font-size: 14px; width: 100%; }
.edit-modal .actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }
.edit-modal .msg { margin-top: 12px; font-size: 13px; }
.edit-modal .msg.err { color: #b02a37; }
.edit-modal .msg.ok { color: #1e7e34; }
