:root {
  color: #e5edf5;
  background: #071724;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { min-width: 360px; margin: 0; background: #071724; }
button, input { font: inherit; }
button { min-height: 34px; padding: 0 13px; border: 1px solid #344458; border-radius: 5px; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #16c7b4; outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #182b3e;
  background: #091827;
}
.brand, .top-actions { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 650; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; background: #103d43; color: #29d6c0; font-size: 11px; font-weight: 800; }
.top-actions { gap: 10px; }
.muted { color: #91a2b6; font-weight: 450; }
.quiet { border-color: #34465a; background: #1b2a3d; color: #d7e1ed; }
.quiet:hover { border-color: #51637a; background: #24364b; }
.primary { border-color: #0eaa9c; background: #0ca99c; color: #f6ffff; font-weight: 650; }
.primary:hover { border-color: #14c4b4; background: #0eb9ab; }

.app-shell { display: grid; min-height: calc(100vh - 60px); grid-template-columns: 224px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 60px;
  display: flex;
  height: calc(100vh - 60px);
  min-height: 440px;
  flex-direction: column;
  padding: 20px 10px 14px;
  border-right: 1px solid #1b2b3e;
  background: #0b1626;
}
.sidebar-caption { padding: 0 14px 12px; color: #61738a; font-size: 10px; font-weight: 700; }
.side-nav { display: grid; gap: 4px; }
.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #acbbcc;
  text-align: left;
}
.nav-link:hover { background: #112638; color: #e5edf5; }
.nav-link[aria-current="page"] { border-left-color: #12c6b2; background: #102d39; color: #2be0ca; font-weight: 650; }
.nav-mark { min-width: 18px; color: #60758d; font-size: 10px; font-variant-numeric: tabular-nums; }
.nav-link[aria-current="page"] .nav-mark { color: #20cdb9; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 14px; border-top: 1px solid #1b2b3e; color: #8293a7; font-size: 11px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #22cc85; box-shadow: 0 0 8px #22cc8560; }

.page-content { min-width: 0; padding: 24px clamp(16px, 3vw, 38px) 52px; }
.message { min-height: 18px; margin: 0; color: #a8b7c8; font-size: 12px; }
.section-heading { display: flex; min-height: 34px; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
.section-heading h1, .section-heading h2 { margin: 0; color: #e8eef6; font-size: 18px; font-weight: 650; }
.section-heading h2 { font-size: 15px; }
.section-heading p { margin: 5px 0 0; color: #8394a8; font-size: 12px; }
.content-section { margin-top: 30px; }
.content-section .section-heading { margin-bottom: 12px; }
.live-heading { align-items: end; }
.search-control { position: relative; display: block; width: min(370px, 52%); }
.search-control input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid #34465a; border-radius: 6px; background: #101e30; color: #e5edf5; font-size: 12px; }
.search-control input::placeholder { color: #78899e; }
.search-symbol { position: absolute; z-index: 1; top: 11px; left: 13px; width: 13px; height: 13px; border: 1.5px solid #8da0b6; border-radius: 50%; }
.search-symbol:after { position: absolute; right: -5px; bottom: -3px; width: 6px; height: 1.5px; transform: rotate(45deg); background: #8da0b6; content: ""; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.metric { display: flex; min-height: 92px; flex-direction: column; justify-content: center; gap: 8px; padding: 15px 17px; border: 1px solid #26384d; border-radius: 7px; background: #101e30; }
.metric span { color: #91a2b6; font-size: 12px; }
.metric strong { color: #f0f5fa; font-size: 25px; font-weight: 650; line-height: 1; }
.metric-alert strong { color: #ff8e70; }

.create-form { display: grid; grid-template-columns: 1.05fr 1.3fr 1fr .7fr .7fr auto; gap: 10px; align-items: end; padding: 14px; border: 1px solid #26384d; border-radius: 7px; background: #101e30; }
.create-form label, .login-form label, .field-label { display: flex; flex-direction: column; gap: 7px; color: #a6b5c7; font-size: 12px; }
.create-form input, .login-form input, .field-label input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #34465a; border-radius: 5px; background: #0b1828; color: #e5edf5; }
.create-form input:focus, .login-form input:focus, .field-label input:focus { outline: 2px solid #0fb5a8; border-color: #0fb5a8; }
.create-form.admin-create-form { grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto; }
.publish-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; margin-bottom: 8px; padding: 16px; border: 1px solid #26384d; border-radius: 7px; background: #101e30; }
.publish-form label { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #a6b5c7; font-size: 12px; }
.publish-form input, .publish-form textarea { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #34465a; border-radius: 5px; background: #0b1828; color: #e5edf5; font: inherit; }
.publish-form input { height: 38px; }
.publish-form textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.publish-form input[type="file"] { height: auto; min-height: 38px; }
.publish-form input:focus, .publish-form textarea:focus { outline: 2px solid #0fb5a8; border-color: #0fb5a8; }
.publish-form .wide-field { grid-column: 1 / -1; }
.publish-form button { justify-self: start; }
.announcement-section .table-wrap { margin-top: 14px; }
.announcement-section td { max-width: 420px; white-space: normal; overflow-wrap: anywhere; }
.announcement-section td:nth-child(4), .announcement-section td:nth-child(5) { white-space: nowrap; }

.table-wrap { overflow: auto; border: 1px solid #293b50; border-radius: 7px; background: #101a2b; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th, td { padding: 12px; border-bottom: 1px solid #213148; text-align: left; vertical-align: middle; }
th { background: #1c2b40; color: #b8c7d8; font-weight: 600; }
td { color: #d2dce7; }
tbody tr { background: #111b2c; }
tbody tr:nth-child(even) { background: #121e31; }
tbody tr:hover { background: #17283a; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row td { height: 72px; color: #7f90a5; text-align: center; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.status:before { width: 7px; height: 7px; border-radius: 50%; background: #8291a2; content: ""; }
.status.active:before, .status.live:before { background: #22cc85; }
.status.disabled:before, .status.error:before { background: #fc6c72; }
.status.live { color: #56dcae; }
.danger { border-color: #683943; background: #412733; color: #ff9a9f; }
.danger:hover { background: #56303d; }
.small-button { min-height: 28px; margin-right: 5px; padding: 0 9px; border-color: #3a4d63; background: #1a2b40; color: #d5e2ef; font-size: 11px; }
.small-button:hover { border-color: #0eb9ab; color: #48e0cc; }
.room-warning, .warning-text { color: #ff9c77; font-weight: 600; }
.empty-state { display: grid; min-height: 240px; place-items: center; border: 1px dashed #34465a; border-radius: 7px; color: #8293a7; font-size: 13px; }

.modal-dialog { width: min(560px, calc(100vw - 28px)); max-height: min(82vh, 760px); overflow: auto; padding: 24px; border: 1px solid #33465d; border-radius: 9px; background: #101e30; color: #e5edf5; box-shadow: 0 24px 80px #0009; }
.modal-dialog::backdrop { background: #020812bd; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.dialog-heading h2 { max-width: 430px; margin: 0; overflow-wrap: anywhere; color: #edf3f9; font-size: 18px; }
.eyebrow { margin: 0 0 7px; color: #22cdb9; font-size: 10px; font-weight: 700; }
.icon-close { width: 34px; min-width: 34px; height: 34px; padding: 0; border: 1px solid #34465a; background: #17273a; color: #c7d4e2; font-size: 20px; line-height: 1; }
.icon-close:hover { color: #fff; background: #263a51; }
.detail-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); margin: 0; border-top: 1px solid #26384d; }
.detail-grid dt, .detail-grid dd { min-width: 0; margin: 0; padding: 12px 8px; border-bottom: 1px solid #26384d; overflow-wrap: anywhere; font-size: 12px; }
.detail-grid dt { color: #8fa0b4; }
.detail-grid dd { color: #e0e8f1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { margin: 7px 0 18px; color: #7f90a5; font-size: 11px; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 20px; color: #c7d4e2; font-size: 12px; cursor: pointer; }
.toggle-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-track { position: relative; width: 34px; height: 19px; border-radius: 12px; background: #46566a; transition: background .15s ease; }
.toggle-track:after { position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: #dbe4ed; content: ""; transition: transform .15s ease; }
.toggle-row input:checked + .toggle-track { background: #0ca99c; }
.toggle-row input:checked + .toggle-track:after { transform: translateX(15px); background: #fff; }
.toggle-row input:focus-visible + .toggle-track { outline: 2px solid #16c7b4; outline-offset: 3px; }

.login-layout { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: #071724; }
.login-form { display: flex; width: min(390px, 100%); flex-direction: column; gap: 15px; padding: 25px; border: 1px solid #293b50; border-radius: 8px; background: #101e30; }
.login-form .brand { margin-bottom: 7px; }
.login-form h1 { margin: 0 0 4px; color: #edf3f9; font-size: 20px; }
.login-form input, .login-form button { height: 40px; }
.login-form button { margin-top: 4px; }
#login-view[hidden], #app-view[hidden] { display: none; }

@media (max-width: 1120px) {
  .create-form { grid-template-columns: repeat(3, minmax(125px, 1fr)); }
  .create-form.admin-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-form.admin-create-form button { grid-column: 1 / -1; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .topbar { height: 54px; padding: 0 14px; }
  .app-shell { display: block; min-height: calc(100vh - 54px); }
  .sidebar { position: sticky; z-index: 2; top: 54px; height: auto; min-height: 0; padding: 0; border-right: 0; border-bottom: 1px solid #1b2b3e; }
  .sidebar-caption, .sidebar-footer { display: none; }
  .side-nav { display: flex; gap: 0; overflow-x: auto; padding: 0 8px; }
  .nav-link { min-width: max-content; min-height: 44px; justify-content: center; padding: 0 12px; border-left: 0; border-bottom: 2px solid transparent; font-size: 12px; }
  .nav-link[aria-current="page"] { border-bottom-color: #12c6b2; background: #102d39; }
  .nav-mark { display: none; }
  .page-content { padding: 20px 12px 36px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 82px; padding: 12px; }
  .metric:nth-child(5) { grid-column: 1 / -1; }
  .create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-form button { grid-column: 1 / -1; }
  .live-heading { align-items: stretch; flex-direction: column; }
  .search-control { width: 100%; }
}

@media (max-width: 420px) {
  .top-actions { gap: 6px; }
  .top-actions button { min-height: 30px; padding: 0 9px; }
  .muted { display: none; }
  .create-form, .settings-fields { grid-template-columns: 1fr; }
  .create-form.admin-create-form { grid-template-columns: 1fr; }
  .publish-form { grid-template-columns: 1fr; padding: 12px; }
  .publish-form .wide-field { grid-column: auto; }
  .create-form button { grid-column: auto; }
  .modal-dialog { padding: 18px; }
  .detail-grid { grid-template-columns: 112px minmax(0, 1fr); }
}
