:root {
  --bg: #e9eef3;
  --surface: #ffffff;
  --surface-raised: #fbfcfd;
  --border: #cdd7e2;
  --border-strong: #aebccd;
  --text: #101820;
  --text-muted: #4f5d6c;
  --accent: #e3b341;
  --accent-soft: #fff7db;
  --blue: #315f7d;
  --blue-hover: #264b63;
  --danger: #c2413a;
  --shadow: 0 14px 34px rgba(16, 27, 39, 0.13);
  --shadow-soft: 0 1px 3px rgba(16, 27, 39, 0.14);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

[hidden] { display: none !important; }

body {
  font-family: 'Segoe UI Variable', 'Segoe UI', Tahoma, sans-serif;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  padding: 0 28px;
  background: rgba(248, 250, 252, 0.95);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px;
  display: block;
  border-radius: 8px;
  object-fit: contain;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0; }

.search-panel input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search-panel input:focus { box-shadow: none; }

.profile-btn {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  text-decoration: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.profile-btn:hover { background: var(--accent-soft); color: var(--text); border-color: #d1a938; transform: translateY(-1px); }

.container { max-width: 1160px; margin: 0 auto; padding: 28px 28px; }
.login-wrap.container { max-width: none; margin: 0; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 18px;
}
.toolbar-search {
  display: flex;
  align-items: center;
  min-width: 38px;
  flex: 1;
}
.search-toggle {
  z-index: 1;
  background: transparent;
  border-color: transparent;
}
.toolbar-search.open {
  max-width: 560px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}
.toolbar-search.open .search-toggle {
  border-color: transparent;
  background: transparent;
  transform: none;
}
.search-panel {
  width: min(500px, calc(100vw - 230px));
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateX(-8px);
  transition: max-width 0.22s ease, opacity 0.16s ease, transform 0.22s ease;
}
.toolbar-search.open .search-panel {
  max-width: 500px;
  opacity: 1;
  transform: translateX(0);
}
.title { font-size: 24px; font-weight: 700; letter-spacing: 0; }
.toolbar-actions { display: flex; align-items: center; gap: 14px; }
.count { color: var(--text-muted); font-size: 14px; }
.btn-icon {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  border-radius: 9px;
  font-size: 15px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.btn-icon:hover { background: #e7eff5; color: var(--blue); border-color: #aebccd; transform: translateY(-1px); }

/* --- View switch --- */
.view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn:hover { background: var(--bg); color: var(--text); }
.view-btn.active { background: #eaf2f6; color: var(--blue); }

/* --- Grid view --- */
.files.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.files.view-table { display: block; }

/* --- Table view (Windows Explorer style) --- */
.file-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.file-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  background: #eef3f7;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.file-table thead th:hover { color: var(--text); }
.file-table thead th.sorted { color: var(--blue); }
.file-table th.th-action { width: 110px; cursor: default; }
.file-table th.th-size, .file-table td.td-size { width: 110px; }
.file-table th.th-date, .file-table td.td-date { width: 170px; white-space: nowrap; }
.file-table th.th-type, .file-table td.td-type { width: 160px; }

.file-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
.file-table tbody tr:last-child { border-bottom: none; }
.file-table tbody tr:hover { background: #f1f6fa; }
.file-table td { padding: 12px 16px; color: var(--text); vertical-align: middle; }
.td-name { display: flex; align-items: center; gap: 10px; }
.row-icon { flex: none; }
.row-name { font-weight: 500; word-break: break-word; }
.td-date, .td-type, .td-size { color: var(--text-muted); font-size: 13px; }

.row-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.row-download:hover { background: var(--blue-hover); }

@media (max-width: 640px) {
  .view-label { display: none; }
  .file-table th.th-type, .file-table td.td-type { display: none; }
  .file-table th.th-date, .file-table td.td-date { width: auto; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(22, 34, 51, 0.11);
  border-color: var(--border-strong);
}

.card-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: #e4edf4;
}
.card-name {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.35;
  min-height: 38px;
}
.card-meta { color: var(--text-muted); font-size: 12.5px; display: flex; justify-content: space-between; }

.card-download {
  margin-top: 4px;
  height: 38px;
  border: none;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
}
.card-download:hover { background: var(--blue-hover); }

.empty {
  text-align: center;
  padding: 54px 20px;
  color: var(--text-muted);
}
.empty-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.empty p { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.ui-icon,
.file-icon,
.download-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: currentColor;
  flex: none;
  mask: center / contain no-repeat;
  -webkit-mask: center / contain no-repeat;
}
.ui-icon-search { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.ui-icon-user { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.ui-icon-home { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 10 9-7 9 7'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 10 9-7 9 7'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E"); }
.ui-icon-list { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E"); }
.ui-icon-grid { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); }
.ui-icon-refresh { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 0 1-15 6.7L3 16'/%3E%3Cpath d='M3 21v-5h5'/%3E%3Cpath d='M3 12a9 9 0 0 1 15-6.7L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 0 1-15 6.7L3 16'/%3E%3Cpath d='M3 21v-5h5'/%3E%3Cpath d='M3 12a9 9 0 0 1 15-6.7L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E"); }
.ui-icon-edit { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E"); }
.ui-icon-trash { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='m19 6-1 14H6L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='m19 6-1 14H6L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
.ui-icon-clock { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.ui-icon-eye { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.ui-icon-arrow-right { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m13 6 6 6-6 6'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m13 6 6 6-6 6'/%3E%3C/svg%3E"); }
.ui-icon-log-out { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='M16 17l5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); }
.download-icon { width: 15px; height: 15px; mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3Cpath d='M5 21h14'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3Cpath d='M5 21h14'/%3E%3C/svg%3E"); }
.file-icon { width: 24px; height: 24px; color: #46657a; mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E"); }
.file-icon-image { color: #2f7d6d; mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='8' cy='10' r='1.5'/%3E%3Cpath d='m21 16-5-5L5 19'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='8' cy='10' r='1.5'/%3E%3Cpath d='m21 16-5-5L5 19'/%3E%3C/svg%3E"); }
.file-icon-video { color: #7c4f8f; }
.file-icon-audio { color: #9a5c2f; }
.file-icon-pdf { color: #b4443f; }
.file-icon-archive { color: #8a6a2a; }
.file-icon-sheet { color: #2f7d48; }
.file-icon-code { color: #315f7d; }

/* ===================== Admin panel ===================== */

.topbar-spacer { flex: 1; }

.btn-text {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.btn-text:hover { background: var(--bg); color: var(--text); }

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93630; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger-sm {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 7px;
  background: #fff0f0;
  color: #e03131;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger-sm:hover { background: #ffe3e3; }
.btn-secondary-sm {
  height: 30px;
  padding: 0 12px;
  margin-right: 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary-sm:hover { background: var(--bg); }

/* Compact row action icon buttons */
.row-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: #eef4f8; border-color: #cbdde8; color: var(--blue); }
.icon-btn-danger:hover { background: #fff1f0; border-color: #f0b7b2; color: var(--danger); }

/* Login */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  height: calc(100vh - 64px);
  overflow: hidden;
  padding: 24px 28px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-logo {
  width: 64px;
  height: 64px;
  align-self: center;
  border-radius: 14px;
  object-fit: contain;
}
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-top: -8px; }
.login-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.password-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.input-action-wrap {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-action-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 125, 0.16);
}
.login-card input {
  width: 100%;
  height: 100%;
  padding: 0 10px 0 14px;
  border: none;
  border-radius: 0;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus { box-shadow: none; }
/* Kill the browser autofill blue background tint on all inputs */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
.modal-input:-webkit-autofill,
.modal-input:-webkit-autofill:hover,
.modal-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #f5f7fa inset;
  box-shadow: 0 0 0 1000px #f5f7fa inset;
}
.field-icon-btn {
  position: static;
  transform: none;
  width: 34px;
  height: 34px;
  margin-right: 5px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.field-icon-btn:hover { background: #e7eff5; color: var(--blue); }
.icon-submit {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
  align-self: center;
}
.form-error {
  color: #e03131;
  font-size: 13.5px;
  font-weight: 500;
  background: #fff0f0;
  border-radius: 8px;
  padding: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 32, 0.32);
  backdrop-filter: blur(6px);
}
.modal {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 22px 52px rgba(16, 27, 39, 0.24);
}
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.modal-message { color: var(--text-muted); font-size: 14px; line-height: 1.45; margin-bottom: 16px; }
.modal-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f5f7fa;
  font-size: 14px;
  outline: none;
}
.modal-input:focus { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 3px rgba(49, 95, 125, 0.16); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.stat-wide { grid-column: 1 / -1; }
.stat-value { font-size: 22px; font-weight: 700; word-break: break-word; line-height: 1.25; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.panel-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--text-muted); font-size: 13.5px; }

/* Admin file table */
.admin-table th.th-check, .admin-table td.td-check { width: 40px; text-align: center; }
.admin-table th.th-action, .admin-table td.td-action { width: 96px; }
.admin-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Settings form */
.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 18px 0;
}
.settings-form.narrow { grid-template-columns: minmax(0, 380px); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field input {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--blue); }
select,
.field select,
.setting-input-select,
.cron-unit {
  height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background-color: #f5f7fa;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text);
  font-size: 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
select:focus,
.field select:focus,
.setting-input-select:focus,
.cron-unit:focus {
  border-color: var(--blue);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(49, 95, 125, 0.16);
}

/* Custom dropdown (replaces native select popup which can't be styled) */
.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
}
.custom-select.cron-unit-select { width: 120px; margin-left: 14px; }
.custom-select > select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background-color: #f5f7fa;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.custom-select-trigger::after {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.18s ease;
}
.custom-select.open .custom-select-trigger {
  border-color: var(--blue);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(49, 95, 125, 0.16);
}
.custom-select.open .custom-select-trigger::after {
  transform: rotate(225deg) translateY(2px);
  border-color: var(--blue);
}
.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  padding: 6px;
  margin: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.custom-select.open .custom-select-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.custom-select-option {
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.custom-select-option:hover,
.custom-select-option.highlighted {
  background: var(--accent-soft);
}
.custom-select-option.selected {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.restart-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #e8590c;
  background: #fff4e6;
  padding: 1px 6px;
  border-radius: 5px;
  margin-left: 4px;
}

/* Cron builder */
#cron-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.setting-input-select {
  min-width: 0;
  width: 100%;
}
.cron-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text);
}
.cron-num {
  width: 64px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  outline: none;
}
.cron-num:focus { border-color: var(--blue); }
.cron-unit { min-width: 120px; }
.cron-weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.cron-day {
  width: 42px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.cron-day:hover { border-color: var(--blue); }
.cron-day.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.cron-time-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.cron-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.cron-radio-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.cron-time {
  height: 36px;
  width: 82px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
.cron-time:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 125, 0.16);
}
.cron-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--blue);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

/* Logs */
.log-view {
  background: #0d1117;
  color: #c9d1d9;
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 60;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid #243546;
  border-radius: 8px;
  background: #172534;
  color: #f6f8fa;
  box-shadow: 0 10px 24px rgba(16, 27, 39, 0.22);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .container { padding: 24px 16px; }
  .toolbar { align-items: flex-start; }
  .search-panel { width: calc(100vw - 100px); }
  .toolbar-actions { gap: 8px; }
  .count { display: none; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--text);
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.2);
  z-index: 100;
}
.toast-success { background: #2f9e44; }
.toast-error { background: #e03131; }
.toast-info { background: var(--text); }
