/* ================= Excel Panel — dizayn tizimi ================= */

:root {
  --bg:        #f5f7fa;
  --panel:     #ffffff;
  --panel-2:   #fafbfc;
  --border:    #e3e8ee;
  --border-2:  #eef1f5;
  --text:      #16202c;
  --muted:     #6b7787;
  --faint:     #99a3b0;

  --accent:    #0f9d58;
  --accent-d:  #0b7a44;
  --accent-l:  #e9f7ef;
  --blue:      #2563eb;
  --blue-l:    #eaf1fe;
  --amber:     #b45309;
  --amber-l:   #fef4e6;
  --danger:    #d33d2e;
  --danger-l:  #fdeceb;

  --shadow-s:  0 1px 2px rgba(18,28,45,.06);
  --shadow:    0 1px 3px rgba(18,28,45,.07), 0 8px 24px -8px rgba(18,28,45,.10);
  --shadow-l:  0 12px 40px -12px rgba(18,28,45,.28);
  --r:         12px;
  --r-s:       9px;
  --sidebar:   248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; margin: 0; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hide  { display: none !important; }
.grow  { flex: 1; }

/* ---------------- layout ---------------- */

.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text);
  padding: 4px 8px 18px;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), #34c77b);
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: 0 2px 8px rgba(15,157,88,.35);
}
.side-nav { display: grid; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-s);
  color: var(--muted); font-weight: 500;
}
.side-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.side-nav a.on { background: var(--accent-l); color: var(--accent-d); font-weight: 600; }
.side-nav a.on svg { color: var(--accent); }
.side-nav svg { width: 18px; height: 18px; flex: none; color: var(--faint); }
.side-nav .pill {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--bg); color: var(--muted);
  padding: 1px 7px; border-radius: 20px;
}
.side-nav a.on .pill { background: #fff; color: var(--accent-d); }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-2); }
.who { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #4b5bdc, #7c3aed); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.who .name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.who a { color: var(--text); }

main.content { padding: 26px 30px 70px; max-width: 1360px; }

/* ---------------- page head ---------------- */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 5px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { color: var(--faint); }
.crumbs .cur { color: var(--text); font-weight: 600; }
.count {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border);
  padding: 2px 9px; border-radius: 20px; vertical-align: middle; margin-left: 6px;
}

/* ---------------- cards & forms ---------------- */

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-s);
  padding: 18px; margin-bottom: 18px;
}
.card.info { display: grid; gap: 8px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form input, .row-form select { flex: 1 1 170px; }
.row-form button { flex: 0 0 auto; }

input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: var(--r-s);
  padding: 9px 12px; outline: none; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,157,88,.13);
}
input::placeholder { color: var(--faint); }
label { display: block; margin-bottom: 13px; font-weight: 500; font-size: 13px; }
label input, label select { margin-top: 6px; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap; font: inherit; font-weight: 550; cursor: pointer;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-s);
  padding: 9px 14px; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--panel-2); border-color: #d3dae3; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(15,157,88,.3);
}
.btn.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--danger); border-color: #f2cdc9; background: #fff; }
.btn.danger:hover { background: var(--danger-l); border-color: #e9b7b1; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { background: #b93325; }
.btn.tiny { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.tiny svg { width: 14px; height: 14px; }
.btn.wide { width: 100%; padding: 11px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.link {
  background: none; border: none; color: var(--accent-d); font: inherit;
  cursor: pointer; padding: 0; text-decoration: underline;
}

.tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
  background: var(--accent-l); color: var(--accent-d); padding: 2px 7px; border-radius: 5px;
}
.tag.blue { background: var(--blue-l); color: var(--blue); }
.tag.amber { background: var(--amber-l); color: var(--amber); }
.tag.grey { background: var(--bg); color: var(--muted); }

/* ---------------- login ---------------- */

.center {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1100px 500px at 50% -8%, #e6f6ee 0%, var(--bg) 60%);
}
.login {
  width: 100%; max-width: 390px; text-align: center; padding: 34px 30px;
  box-shadow: var(--shadow-l); border-radius: 16px;
}
.login .logo {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), #34c77b);
  display: grid; place-items: center; font-size: 26px;
  box-shadow: 0 6px 18px rgba(15,157,88,.35);
}
.login h1 { margin-bottom: 5px; }
.login p { margin: 6px 0 22px; }
.login label { text-align: left; }
.login.narrow { max-width: 440px; margin: 0; text-align: left; box-shadow: var(--shadow-s); }

/* ---------------- flash ---------------- */

.flashes { position: fixed; top: 22px; right: 22px; z-index: 200; display: grid; gap: 9px; }
.flash {
  padding: 12px 16px; border-radius: var(--r-s); box-shadow: var(--shadow);
  background: var(--accent-l); color: var(--accent-d); border: 1px solid #bfe6cf;
  max-width: 380px; font-weight: 550; animation: pop .22s ease-out;
}
.flash.error { background: var(--danger-l); color: #9c2b1f; border-color: #f2c4be; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

/* ---------------- dropzone ---------------- */

.dropzone {
  border: 2px dashed #d5dce4; box-shadow: none; cursor: pointer;
  background: var(--panel); transition: .15s;
}
.dropzone:hover { border-color: #bcc7d2; background: var(--panel-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-l); }
.dz-body { text-align: center; padding: 12px; }
.dz-icon { font-size: 26px; margin-bottom: 6px; }
.picked { text-align: center; color: var(--accent-d); font-weight: 600; padding-bottom: 8px; }

/* ---------------- search ---------------- */

.search { position: relative; }
.search input { width: 260px; padding-left: 34px; }
.search .ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--faint); pointer-events: none;
}
.search .clear {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: 13px;
}

/* ---------------- papkalar ---------------- */

.folder-grid {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.folder {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-s); color: var(--text);
  transition: .13s; position: relative;
}
.folder:hover {
  text-decoration: none; border-color: #cfd8e2; box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.folder .fi { font-size: 22px; line-height: 1; }
.folder .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .sub { font-size: 12px; color: var(--faint); }
.folder .menu { margin-left: auto; }

.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--faint); margin: 4px 0 10px;
}

/* ---------------- table ---------------- */

.table-wrap {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-s); overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--faint); font-weight: 700;
  padding: 11px 16px; background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: var(--panel-2); }
.fname { font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 9px; }
.fname:hover { color: var(--accent-d); text-decoration: none; }
.fico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 14px;
  background: var(--accent-l); color: var(--accent-d);
}
.fico.csv { background: var(--blue-l); color: var(--blue); }
.actions { text-align: right; white-space: nowrap; }
.actions form, .inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.actions > *, .actions form { vertical-align: middle; }
.actions > * + * { margin-left: 6px; }
.inline input { width: 140px; padding: 6px 9px; font-size: 12.5px; }
.inline select { width: auto; padding: 6px 9px; font-size: 12.5px; }

.empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--border);
  border-radius: var(--r);
}
.empty .big { font-size: 34px; margin-bottom: 10px; }

/* ---------------- modal ---------------- */

dialog.modal {
  border: none; border-radius: 15px; padding: 0; width: min(430px, 92vw);
  box-shadow: var(--shadow-l); color: var(--text);
}
dialog.modal::backdrop { background: rgba(16,26,40,.5); backdrop-filter: blur(2px); }
.modal-body { padding: 24px 24px 20px; }
.modal-body h3 { margin: 0 0 6px; font-size: 17px; }
.modal-body p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.modal-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 21px; margin-bottom: 13px; background: var(--danger-l);
}
.modal-icon.warn { background: var(--amber-l); }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }
.modal-foot .btn { min-width: 96px; }

/* ---------------- muharrir ustidagi panel ---------------- */

.editor-bar {
  height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: #1f2b38; color: #fff; position: relative; z-index: 5;
}
.editor-bar .idle {
  font-size: 12.5px; color: #ffca7a; font-weight: 600;
}
.editor-bar .back {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 7px 13px; font: inherit; font-weight: 600; font-size: 13.5px;
  box-shadow: 0 1px 6px rgba(15,157,88,.35);
}
.editor-bar .back svg { width: 15px; height: 15px; }
.editor-bar .back:hover { background: #12b365; }
.editor-bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-bar .hint { margin-left: auto; font-size: 12.5px; color: #9fb0c0; }

/* ---------------- excel grid (tez ko'rish) ---------------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.sheets { display: flex; gap: 4px; flex-wrap: wrap; }
.sheet-tab {
  font: inherit; cursor: pointer; padding: 7px 14px; border-radius: 9px 9px 0 0;
  background: var(--panel); border: 1px solid var(--border); border-bottom: none;
  color: var(--muted); font-weight: 500;
}
.sheet-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.tools { display: flex; gap: 6px; align-items: center; }
.dirty { font-size: 12.5px; color: var(--amber); font-weight: 650; }

.grid-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-s);
  overflow: auto; max-height: 68vh;
}
.loading { padding: 44px; text-align: center; color: var(--muted); }

table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th, table.grid td {
  border-right: 1px solid var(--border-2); border-bottom: 1px solid var(--border-2);
  padding: 5px 9px; min-width: 92px; max-width: 340px; height: 31px;
  white-space: pre; overflow: hidden; text-overflow: ellipsis;
}
table.grid thead th {
  position: sticky; top: 0; z-index: 3; background: var(--panel-2);
  text-align: center; font-weight: 650; color: var(--muted); font-size: 12px;
}
table.grid th.corner, table.grid td.rownum {
  position: sticky; left: 0; z-index: 2; background: var(--panel-2);
  text-align: center; color: var(--faint); font-weight: 650;
  min-width: 54px; width: 54px; font-size: 12px; user-select: none;
}
table.grid th.corner { z-index: 4; }
table.grid td[contenteditable] { background: #fff; cursor: cell; }
table.grid td[contenteditable]:focus {
  outline: 2px solid var(--accent); outline-offset: -2px; overflow: visible;
  white-space: pre-wrap; background: #fff; position: relative; z-index: 1;
}
table.grid td.changed { background: #fff8e6; }
table.grid td.hit { background: #ffeaa7; }
table.grid tr:hover td.rownum { background: #e8edf2; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }
.pager .info { color: var(--muted); font-size: 13px; }

/* ---------------- mobil ---------------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 10px 14px; overflow-x: auto; gap: 10px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 8px 0 0; }
  .brand span:not(.logo) { display: none; }
  .side-nav { display: flex; gap: 4px; }
  .side-nav a { padding: 8px 10px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: none; }
  .who .name, .who .small { display: none; }
  main.content { padding: 18px 14px 50px; }
  .search input { width: 100%; }
  .page-head { width: 100%; }
  .table-wrap { overflow-x: auto; }
  .table { min-width: 620px; }
}
