:root {
  --black1: #121214;
  --black2: #8b8b93;
  --divider: #232327;
  --white: #FFFFFF;
  --red: #FF5C5C;
  --redTransparent: rgba(255, 92, 92, 0.7);
  --blue: #F2524E;

  --bg: var(--black1);
  --surface: #1a1a1e;
  --surface-2: #202024;
  --border: #2a2a2f;
  --text: #f2f2f3;
  --text-muted: #9a9aa2;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Pretendard, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 14px;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

button:hover {
  background: #26262b;
}

button:active {
  transform: scale(0.98);
}

input, textarea {
  font-family: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

input:focus, textarea:focus, button:focus {
  outline: none;
  border-color: var(--blue);
}

/* ---------- sidebar ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  z-index: 10;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 22px;
}

.sidebar-brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(242, 82, 78, 0.15);
}

.sidebar-brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--white);
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  border: 1px solid transparent;
}

.sidebar-link i {
  font-size: 15px;
  width: 16px;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(242, 82, 78, 0.12);
  color: var(--white);
}

.sidebar-link.active i {
  color: var(--blue);
}

/* ---------- page shell ---------- */

body.has-sidebar {
  min-height: 100vh;
  background-color: var(--bg);
  padding: 28px 32px 60px calc(var(--sidebar-w) + 32px);
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* ---------- shared table look ---------- */

body.has-sidebar table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

body.has-sidebar table th,
body.has-sidebar table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
  color: var(--text);
  font-size: 14px;
}

body.has-sidebar table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

body.has-sidebar table tr.row-selected td {
  background: rgba(242, 82, 78, 0.16);
}

body.has-sidebar table td button {
  margin: 4px 6px 4px 0;
  white-space: nowrap;
}

/* ---------- responsive ---------- */

@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    margin: -18px -16px 20px;
    width: calc(100% + 32px);
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-brand {
    padding: 0 12px 0 2px;
    margin-right: 8px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }

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

  .sidebar-link {
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--surface-2);
    border-color: var(--border);
  }

  .sidebar-link.active {
    background: rgba(242, 82, 78, 0.18);
  }

  body.has-sidebar {
    padding: 18px 16px 48px;
  }

  body.has-sidebar table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  body.has-sidebar table td:not(:has(button)) {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 18px;
  }

  body.has-sidebar table th,
  body.has-sidebar table td {
    padding: 8px;
    font-size: 13px;
  }

  body.has-sidebar table td:not(:has(button)) {
    max-width: 110px;
  }
}
