:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --line: #d7e1ec;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0f4c81;
  --accent-hover: #0c3d69;
  --accent-soft: #eaf2fb;
  --secondary: #e9eef5;
  --secondary-hover: #dde6f0;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;
  --info-bg: #dbeafe;
  --info-text: #1d4ed8;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8fc 100%);
  border-right: 1px solid var(--line);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.6);
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-bottom {
  padding-top: 18px;
}

.brand-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 4px;
}

.brand-logo-card {
  width: 128px;
  height: 128px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #edf4fb 100%);
  border: 1px solid #d9e6f3;
  box-shadow:
    0 12px 28px rgba(15, 76, 129, 0.08),
    inset 0 1px 0 rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.brand-logo {
  width: 98px;
  height: 98px;
  object-fit: contain;
  border-radius: 20px;
}

.user-box {
  background: #f7fbff;
  border: 1px solid #dde8f3;
  border-radius: 18px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.user-name {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #0d2342;
}

.user-role {
  font-size: 14px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.sidebar-nav a {
  text-decoration: none;
  padding: 13px 15px;
  border-radius: 14px;
  color: #0f172a;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-nav a:hover {
  background: #e7f0fb;
  color: var(--accent);
  transform: translateX(2px);
}

.sidebar-nav a.active {
  background: linear-gradient(180deg, #0f4c81 0%, #0c3f6b 100%);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(15, 76, 129, 0.18);
}

.sidebar-logout {
  width: 100%;
  justify-content: center;
  font-weight: 700;
}

/* Content */
.content {
  flex: 1;
  padding: 34px 40px 40px;
}

.page-title {
  margin: 0 0 28px;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 800;
  color: #082042;
}

/* Grid */
.grid {
  display: grid;
  gap: 22px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

/* Stats */
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  min-height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow);
}

.stat .label {
  font-size: 15px;
  color: #47607d;
  margin-bottom: 14px;
  text-align: center;
}

.stat .value {
  font-size: 38px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  text-align: center;
}

/* Buttons */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 76, 129, 0.18);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #1e293b;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-danger {
  background: #b42318;
  color: #fff;
}

.btn-danger:hover {
  background: #912018;
}

.btn-ok {
  background: #15803d;
  color: #fff;
}

.btn-ok:hover {
  background: #166534;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-primary {
  background: #dbeafe;
  color: #1e3a8a;
}

.badge-secondary {
  background: #eef2f7;
  color: #475569;
}

.badge-ok {
  background: var(--success-bg);
  color: var(--success-text);
}

/* Forms */
.row {
  margin-bottom: 18px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 13px 15px;
  font: inherit;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #7aa7d9;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

textarea {
  resize: vertical;
  min-height: 130px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid #e6edf5;
  vertical-align: middle;
}

th {
  font-size: 13px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: #f8fbff;
}

/* Notices */
.notice {
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

.notice.ok {
  background: #ecfdf3;
  border: 1px solid #b7ebc6;
  color: #166534;
}

.notice.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.small {
  font-size: 14px;
  color: #475569;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px 18px;
}

.kv div {
  padding: 10px 0;
  border-bottom: 1px solid #e5edf6;
}

img.preview {
  max-width: 280px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

/* Responsive */
@media (max-width: 1500px) {
  .grid-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 28px 24px 32px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 18px 16px;
  }

  .sidebar-top {
    gap: 14px;
  }

  .brand-logo-card {
    width: 108px;
    height: 108px;
    border-radius: 24px;
    padding: 8px;
  }

  .brand-logo {
    width: 82px;
    height: 82px;
    border-radius: 18px;
  }

  .user-box {
    padding: 16px 14px;
  }

  .sidebar-nav a {
    padding: 12px 14px;
  }

  .content {
    padding: 20px 16px 28px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .kv {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 28px;
  }
}