:root {
  --bg: #f3f4f8;
  --card: #ffffff;
  --line: #e7e9f0;
  --text: #1f2430;
  --muted: #7b8399;
  --primary: #ff8d2a;
  --primary-dark: #ef7d1c;
  --success: #1ea86f;
  --danger: #df4b57;
  --shadow: 0 8px 24px rgba(32, 43, 67, 0.08);
}

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

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

input,
select,
button {
  font: inherit;
}

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

.brand-icon {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary);
  border-radius: 5px;
  transform: rotate(45deg);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  text-decoration: none;
  color: #596077;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}

.nav-item.active,
.nav-item:hover {
  background: #fff4ea;
  color: var(--primary-dark);
}

.sidebar-status {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
}

.sidebar-status p {
  margin: 0 0 8px;
  color: #474e63;
  font-weight: 600;
}

.sidebar-status span {
  color: var(--success);
  font-weight: 600;
}

.dashboard-container {
  padding: 18px;
}

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.page-path {
  font-size: 14px;
  color: #666f86;
}

.logout-btn {
  border: 1px solid #ffd0b0;
  color: #a84a00;
  background: #fff6ef;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.dashboard-header,
.admin-block,
.info-section,
.form-section,
.companies-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.dashboard-header {
  padding: 18px 22px;
  margin-bottom: 14px;
}

.dashboard-header h2 {
  margin: 0 0 4px;
  font-size: 28px;
}

.dashboard-header p {
  margin: 0;
  color: #6f7890;
}

.admin-block {
  overflow: hidden;
}

.block-header {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  background: #fcfcfe;
}

.block-header h3 {
  margin: 0;
  font-size: 16px;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.stat-card h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #5a637b;
  font-size: 13px;
}

.stat-item:last-child {
  margin-bottom: 0;
}

.stat-value {
  color: #171d2d;
  font-weight: 700;
}

.export-card .export-section {
  padding: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.search-section,
.user-form,
.bulk-operations,
.users-list,
.backup-section,
.logs-section,
.sessions-controls,
.sessions-list,
.blocked-companies-section {
  padding: 12px 14px;
}

.user-form,
.bulk-operations,
.search-section {
  border-bottom: 1px solid var(--line);
}

.search-controls {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr) auto;
  gap: 8px;
}

.bulk-controls {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  border: 1px solid #d8dce8;
  border-radius: 9px;
  padding: 9px 10px;
  background: #fff;
  color: #1e2537;
}

input:focus,
select:focus {
  outline: none;
  border-color: #a8b1ca;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

button,
.btn,
.action-link {
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.2s ease;
}

button[type="submit"],
.search-btn,
.export-btn,
.backup-btn,
.logs-btn,
.action-link,
.btn-primary {
  background: linear-gradient(180deg, #ff983e 0%, #ff8a2b 100%);
  color: #fff;
  border-color: #ffca9f;
}

.search-btn:hover,
.export-btn:hover,
.backup-btn:hover,
.logs-btn:hover,
.action-link:hover,
.btn-primary:hover,
button[type="submit"]:hover {
  background: linear-gradient(180deg, #ff9030 0%, #f67c1b 100%);
}

.bulk-btn,
.pagination-btn,
.btn-secondary {
  background: #f5f7fb;
  border-color: #dce0eb;
  color: #485066;
}

.bulk-btn.danger,
.logout-all-btn,
.delete-btn,
.btn-delete,
.admin-btn.revoke {
  background: #ffeff0;
  border-color: #ffc4ca;
  color: #c53f4b;
}

.admin-btn.grant,
.cleanup-btn,
.refresh-btn,
.btn-success {
  background: #eaf8f1;
  border-color: #bfe8d4;
  color: #127047;
}

.table-container {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid #eef1f7;
  text-align: left;
  font-size: 13px;
}

th {
  color: #6a7289;
  background: #fafbfe;
  font-weight: 600;
}

tr:hover {
  background: #fcfdff;
}

.action-buttons {
  display: flex;
  gap: 6px;
}

.tag-btn {
  border-radius: 999px;
  padding: 4px 9px;
  border: none;
  font-size: 11px;
}

.tag-rz {
  background: #e6f8ef;
  color: #1d8e5f;
}

.tag-lb {
  background: #ecf3ff;
  color: #3c70c9;
}

.tag-kr {
  background: #f1ebff;
  color: #7448c2;
}

.tag-none {
  background: #f0f1f5;
  color: #646d84;
}

.status-badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.user {
  background: #eaf8f1;
  color: #16804f;
}

.status-badge.admin {
  background: #fff0f1;
  color: #c8414f;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

#pageInfo {
  color: #5f677e;
  font-size: 13px;
}

.dashboard-sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
}

.backup-item {
  border: 1px solid #e7eaf1;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.restore-btn {
  background: #f5f7fb;
  border: 1px solid #dbe0ea;
  color: #4d566d;
  border-radius: 8px;
  padding: 6px 10px;
}

.logs-container {
  margin-top: 9px;
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid #e8ebf3;
  border-radius: 10px;
  background: #fafbfe;
}

.log-entry {
  padding: 7px 9px;
  border-bottom: 1px solid #eceff6;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.log-level-info {
  color: #3056b2;
}

.log-level-warn {
  color: #936d08;
}

.log-level-error {
  color: #bc3340;
}

.dashboard-bottom {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-home-grid,
.software-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.home-card-content {
  padding: 16px;
}

.home-card-content p {
  margin: 0 0 14px;
  color: #6a7289;
  line-height: 1.55;
}

.analytics-block {
  grid-column: 1 / -1;
}

.software-card {
  min-height: 220px;
}

.release-details {
  margin-bottom: 14px;
}

.release-details p {
  margin: 0 0 7px;
}

.install-guide {
  margin-top: 14px;
}

.blocked-companies-section p {
  margin: 0 0 10px;
  color: #6a7289;
}

.sessions-block {
  margin-top: 14px;
}

#lastUpdate {
  margin-bottom: 8px;
  color: #7a8298;
  font-size: 12px;
}

.logout-user-btn {
  background: #f5f7fb;
  border: 1px solid #dbe0ea;
  color: #4e5670;
}

.status-online {
  color: #178450;
  font-weight: 600;
}

.status-offline {
  color: #7f869a;
}

.error-message,
.result-message.error {
  margin-top: 8px;
  color: #c64653;
  background: #ffeff1;
  border: 1px solid #ffc7cf;
  border-radius: 9px;
  padding: 8px 10px;
}

.success-message,
.result-message.success {
  margin-top: 8px;
  color: #1b7f53;
  background: #eaf8f1;
  border: 1px solid #c2ead7;
  border-radius: 9px;
  padding: 8px 10px;
}

.result-message {
  margin-top: 8px;
}

/* Auth page */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8f9fc 0%, #f1f3f8 100%);
}

.auth-topbar {
  padding: 20px 24px 6px;
}

.auth-main {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-container {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-container h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.login-container > p {
  margin: 0 0 18px;
  color: #6f7890;
}

.login-container label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #535b72;
}

.login-container input {
  margin-bottom: 12px;
}

.login-container button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.auth-hint {
  margin-top: 14px;
  color: #7a8399;
  font-size: 12px;
  text-align: center;
}

#message {
  margin-top: 10px;
}

/* Blocked companies page */
.blocked-companies-container {
  max-width: 1200px;
}

.blocked-header h2 {
  font-size: 24px;
}

.back-link {
  text-decoration: none;
  color: #5f6880;
  font-weight: 600;
}

.info-section,
.form-section,
.companies-list {
  padding: 14px;
  margin-bottom: 12px;
}

.info-section h4,
.form-section h3,
.companies-list h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.info-item {
  margin-bottom: 6px;
  color: #5f6880;
}

.info-label {
  color: #444d65;
  font-weight: 600;
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #535c73;
}

.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.install-box {
  margin-top: 10px;
  border: 1px solid #e7eaf1;
  border-radius: 10px;
  background: #fafbfd;
  padding: 12px;
}

.install-box h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.install-box ol {
  margin: 0;
  padding-left: 18px;
  color: #5d657b;
  line-height: 1.65;
}

.install-box code {
  background: #eef2f8;
  padding: 2px 6px;
  border-radius: 4px;
}

.install-note {
  color: #7f889f;
  font-size: 12px;
  margin-top: 9px;
}

.companies-list {
  max-height: 420px;
  overflow-y: auto;
}

.company-item {
  border: 1px solid #e7ebf3;
  border-radius: 10px;
  padding: 9px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.company-id {
  color: #c76d20;
  font-weight: 600;
  word-break: break-all;
}

.company-reason {
  color: #6f7790;
  font-size: 12px;
  margin-top: 4px;
}

@media (max-width: 1240px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .export-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }

  .sidebar-status {
    margin-top: 0;
  }

  .dashboard-grid,
  .dashboard-bottom,
  .dashboard-home-grid,
  .software-grid {
    grid-template-columns: 1fr;
  }

  .search-controls,
  .bulk-controls,
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard-container {
    padding: 10px;
  }

  .dashboard-header h2 {
    font-size: 22px;
  }

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